Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to extract PSX roms in 7z / bin / ape format.
#!/bin/bash -eux
# Extracts and load PSX games that are distributed in .7z / .ape format.
# Requires : ffmpeg, perl, cdemu, ecm2bin
GAME_FOLDER="$1"
EXTRACT_FOLDER=/tmp/game
rm -rf "$EXTRACT_FOLDER"
mkdir "$EXTRACT_FOLDER"
cp -rf "$GAME_FOLDER"/* "$EXTRACT_FOLDER"
cd "$EXTRACT_FOLDER"
# Game files
for GAME_DATA in *.7z
do
GAME_DATA_NOEXT="${GAME_DATA%.7z}"
7z x "$GAME_DATA"
ECM_DATA=$(find . -name '*.bin.ecm' | head -n 1)
ECM_DATA_NOEXT="${ECM_DATA%.bin.ecm}"
ecm2bin "$ECM_DATA"
mv "$ECM_DATA_NOEXT.bin" "$GAME_DATA_NOEXT.bin"
rm -f "$ECM_DATA" "$GAME_DATA"
done
# Audio
if stat -t *.ape >/dev/null 2>&1; then
for AUDIO_DATA in *.ape
do
AUDIO_NOEXT="${AUDIO_DATA%.ape}"
ffmpeg -i "$AUDIO_DATA" "$AUDIO_NOEXT.wav"
mv "$AUDIO_NOEXT.wav" "$AUDIO_NOEXT.bin"
done
fi
# Remove all special chars in the cue sheet because of cdemu bugs
counter=0
for BIN_FILE in *.bin
do
mv "$BIN_FILE" "$counter.bin"
perl -pi -e "s/\Q${BIN_FILE}\E/$counter.bin/g" *.cue
let counter=counter+1
done
CUESHEET=$(find . -name '*.cue')
mv "$CUESHEET" game.cue
# Load with cdemu
cdemu unload 0
sleep 1
cdemu load 0 game.cue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment