Skip to content

Instantly share code, notes, and snippets.

@luigidifraia
Last active September 5, 2020 19:29
Show Gist options
  • Save luigidifraia/274d9bf7ad08b1f058ad7d6fb105e163 to your computer and use it in GitHub Desktop.
Save luigidifraia/274d9bf7ad08b1f058ad7d6fb105e163 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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