Created
April 5, 2023 01:56
-
-
Save egladman/ed5ac4ebd670ff7cc14460a497556d9d to your computer and use it in GitHub Desktop.
Create m3u playlist for multi disk media/games
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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