Skip to content

Instantly share code, notes, and snippets.

@egladman
Created April 5, 2023 01:56
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 egladman/ed5ac4ebd670ff7cc14460a497556d9d to your computer and use it in GitHub Desktop.
Save egladman/ed5ac4ebd670ff7cc14460a497556d9d to your computer and use it in GitHub Desktop.
Create m3u playlist for multi disk media/games
#!/bin/bash
set -eu
# Usage: ./generate-m3u.sh <path/to/dir>
# Creates a .m3u playlist for media/games that have one .cue/.bin file per disk
# Expects the following directory structure
# FooBarBaz
# FooBarBaz.m3u
# skdcnskjdnc.cue
# cdscdskcdsk.cue
# The cue files do NOT need to follow any naming conventions
main() {
base_dir="${1:?}"
for f in "${base_dir}"/*; do
if [[ ! -d "$f" ]]; then
continue
fi
title_dir="$(basename "$f")"
pushd "$f"
m3u_file="${title_dir}.m3u"
>"$m3u_file"
for ff in *.cue; do
printf '%s\n' "$ff" >> "$m3u_file"
done
popd
done
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment