Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rename TAP files to include the name of the first CBM ROM file therein
#!/bin/bash
# Pre: make sure you have the find-rom-name binary available in your PATH
# binaries available @ https://www.luigidifraia.com/software/#Filename_extractors
for filename in *.TAP; do
echo -n "Parsing $filename: "
cbm_name=$(find-rom-name "$filename" | grep "^FOUND:" | awk '{ print $2 }' | sed -e "s/\"//g")
if [ ! -z $cbm_name ]; then
mv "${filename}" "${filename%.*}_${cbm_name}.${filename##*.}"
echo "INFO: renamed"
else
echo "WARNING: boot name not found"
fi
done
@luigidifraia

This comment has been minimized.

Owner

luigidifraia commented Sep 3, 2018

This script runs in a bash shell under *Nix and can be run within a Git bash shell under Windows, or similar.

Add the following line after the mv command in order to also rename the DMP file that corresponds to a TAP file being renamed:
mv "${filename%.*}.DMP" "${filename%.*}_${cbm_name}.DMP"

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