Update to My Renaming Script

A while back I wrote a post on renaming FLAC files to include their associated disc numbers. For example, if you have a file from disc 1 named “01 – Track Name.flac” my script would change it to “01.01 – Track Name.flac”.

This updated version of the script allows the user to enter the path to the folder needing files renamed and the associated disc number.

I think this is a slightly simpler method than my previous method for using this script. You can read about the original script here.

Here is the current script:

# by JamesIsIn from JamesIsIn.com
# Do something nice today.

# Prepend album number before track numbers
# 01 - Track Name.flac becomes 01.01 - Track Name.flac

echo "This script will change FLAC file names based on a containing folder and a disc number which you supply."
echo "Example:  "01 - Track Name.flac" becomes "01.01 - Track Name.flac""

read -p "I will require the path to the containing folder: "
if [ -d "$REPLY" ]; then
printf "I have confirmed this is a directory.nn"
printf "I cannot find this directory.nn"
exit 1

read -p "Which disc number, please (01 through 99): "
# add test for 01-99
printf "%bnn" "I will prepend $REPLY to all FLAC files in: $directorynn"

read -p "Press <ENTER> to continue (ctrl-c will abort)."

cd "$directory"

rename "s/^/$newname./" *.[Ff][Ll][Aa][Cc]

This version also handles FLAC extensions in any case (flac=FLAC=FlAc &c).

If I make any updates, I’ll likely just change this post. As such, I should say that this current version is current as of 8 March 2010.

Have fun with that.


3 thoughts on “Update to My Renaming Script

  1. I have an updated version of this script coming, and I’ll be moving the actual script over to github or similar. Watch for that. For now I wanted to offer this tutorial I found for renaming using Python.

Leave a Reply

Your email address will not be published. Required fields are marked *