Skip to content

Instantly share code, notes, and snippets.

@mikeyjk
Last active February 9, 2023 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeyjk/5dca61262cc1ae04a49c2f4834ed95d2 to your computer and use it in GitHub Desktop.
Save mikeyjk/5dca61262cc1ae04a49c2f4834ed95d2 to your computer and use it in GitHub Desktop.
generate m3u's for backups of PS1 games you own the original hardware for, that are in .7z or .cue format
#!/usr/bin/env bash
# Usage: ./generate_psx_m3u.sh
# small tweak on: https://github.com/danyboy666/Generate-PSX-m3u-playlist/blob/master/generate_psx_m3u.sh
for rom in *{.rar,.chd,.zip,.pbp,.PBP,.7z,.cue}; do
if [[ $rom =~ ^.*[dD]is[ckCK].*$ ]]; then
playlistName=$(echo "$rom" | sed 's/.rar//g;s/.chd//g;s/.zip//g;s/.pbp//g;s/.PBP//g;s/.7z//g;s/.cue//g;s/\s[\(][dD]is[ckCK]\s[0-9]\{1,2\})//g')
echo -e "rom: $rom"
echo -e "playlist: $playlistName"
echo "$rom" >> "$playlistName"".m3u"
fi
done
@mikeyjk
Copy link
Author

mikeyjk commented Feb 9, 2023

what I was going for:

  • retains other stuff in brackets, e.g. (VR-Disc), (v1.1)
  • slightly catering for trash roms named badly
  • handle 7z
    • damn, psx cores don't load 7z

e.g. output

Metal Gear Solid (USA) (v1.1).m3u
    Metal Gear Solid (USA) (Disc 1) (v1.1).7z
    Metal Gear Solid (USA) (Disc 2) (v1.1).7z

Metal Gear Solid - Integral (Japan) (En,Ja).m3u
    Metal Gear Solid - Integral (Japan) (En,Ja) (Disc 1).7z
    Metal Gear Solid - Integral (Japan) (En,Ja) (Disc 2).7z

Metal Gear Solid - Integral (Japan) (VR-Disc).m3u
    Metal Gear Solid - Integral (Japan) (Disc 3) (VR-Disc).7z

Resident Evil 2 - Dual Shock Ver. (USA) (Claire).m3u
    Resident Evil 2 - Dual Shock Ver. (USA) (Disc 2) (Claire).7z

Resident Evil 2 - Dual Shock Ver. (USA) (Leon).m3u
    Resident Evil 2 - Dual Shock Ver. (USA) (Disc 1) (Leon).7z

I'm happy enough with how that's behaving, although I'm open to convincing there's a better way (perhaps a per game behaviour)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment