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:

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

echo
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.\n\n"
directory="$REPLY"
else
printf "I cannot find this directory.\n\n"
exit 1
fi

read -p "Which disc number, please (01 through 99): "
# add test for 01-99
printf "%b\n\n" "I will prepend $REPLY to all FLAC files in: $directory\n\n"
newname=$REPLY

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

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.

JamesIsIn
  • Share/Bookmark

Tags: , , ,

-- ==
-- ==

2 Responses to “Update to My Renaming Script”

  1. James Cook JamesIsIn says:

    Fixed to allow spaces in directory path.

Leave a Reply