#!/bin/bash IFS=$'\n' if [ -z "${1}" ]; then echo "Usage: ${0} /path/to/PS3ISO" echo "Path can be relative. 7z archives will be generated in cwd." exit 1; fi PS3ISO=${1} extract=("PS3_DISC.SFB" "PS3_GAME/PARAM.SFO" "PS3_GAME/USRDIR/EBOOT.BIN" "PS3_GAME/LICDIR/LIC.DAT"); function extract_file() { if [ -f "${1}" ]; then "/c/Program Files/7-Zip/7z.exe" x -aoa "$(cygpath -w "${1}")" "${2}" 2>/dev/null > /dev/null echo $? else echo 1 fi } for f in $(ls -1 "${PS3ISO}"); do f=$(realpath "${PS3ISO}/${f}") if [ -f "${f}" ]; then if [ $(echo "${f}" | grep "\^" | wc -l) -eq 0 ]; then TBS=$(echo "${f}" | rev | cut -d'/' -f1 | rev) TID=$(echo "${TBS}" | cut -d'-' -f1) TIT=$(echo "${TBS}" | cut -d'[' -f2) TIT=$(echo "${TIT}" | cut -d']' -f1) EXT=$(echo "${TBS}" | rev | cut -d'.' -f1 | rev) ZIP="[${TID}] ${TIT}" if [ "${EXT}" != "iso" ]; then continue; fi echo "Processing ${f}..." mkdir "${ZIP}" cd "${ZIP}" for e in "${extract[@]}"; do if [ $(extract_file "${f}" "${e}") -eq 0 ]; then echo "Extract from ${f}: ${e}... success." fi done if [ $(stat -c '%s' "PS3_GAME/USRDIR/EBOOT.BIN") -gt 0 ] && [ $(stat -c '%s' "PS3_GAME/PARAM.SFO") -gt 0 ]; then echo -n "Creating ${ZIP}.7z..." "/c/Program Files/7-Zip/7z.exe" u -m0=lzma2:d=1024m -mx=9 -aoa -mfb=64 -md=32m -ms=off -xr!z_archive.log -r "../${ZIP}.7z" . 2>&1 > z_archive.log res_7z=$? if [ ${res_7z} -ne 0 ]; then echo " failed." cat z_archive.log else echo " success" echo "" fi else echo "ERROR: Missing files for ${ZIP}" fi cd .. rm -f z_archive.log rm -rf "./${ZIP}" fi fi done