As you may have heard, I’m building a music server for my home (aka my local network). I’m rippin’ dem discs down to .flac files and stowing dem on a phat drive. Caught between geek and gangster, I’m having a good time.
I am using Sound Juicer to squeeze my CD’s into flacs. You can read about my encoding woes and solutions here.
Sound Juicer: Applications —> Sound & Video —> Audio CD Extractor
One thing about using Sound Juicer is that it likes to put all the files for an album or boxset into a single folder with the name of that album or boxset (under a folder with the name of the person or band or whatever). That works out fine if you rip single albums (like Pink Floyd’s Meddle, for instance). It creates files with the track numbers (optional, but I like it) and track names:
01 One Of These Days.flac
As you can see, that’s pretty straight forward. Where I run into trouble is when I rip a boxset, such as The Immortal Soul of Al Green. This is a four disc set. Sound Juicer wants to create a folder called “The Immortal Soul of Al Green” and put all of the tracks into that folder. That means I have four track ones and four track twos…
Ack! What a mess that is.
So I did some hunting around the web and got some help from this blogger here, and I wrote a script that would do me a favor.
I don’t really want to create folders called “The Immortal Soul of Al Green CD1” and “The Immortal Soul of Al Green CD2” all the way down the line for each double album and boxset I encounter. Instead I will be satisfied by prepending each track number with the corresponding disc number for that particular album. Single albums I will not change.
So, for the album “The Immortal Soul of Al Green” I will run a script on those files for disc three such that the files will change as follows:
01 Take Me To The River.flac —> 03.01 Take Me To The River.flac
This tells me that this song is the first track on the third disc of this set. Using this method keeps all of the songs from this boxset in one folder (called “The Immortal Soul of Al Green”) under the folder in my collection called Al Green. Further, when I look in this folder all of the songs are in order. Very convenient and easy to comprehend.
At first I was doing this by renaming each file as they were ripped. Lame. Oh, so very lame. Curdled lameness.
(I have updated this renaming script. You can find that new version here.)
Here is the script I settled upon thanks to a little research and some kind coders far and wide:
for filename in *.flac do mv "$filename" ../Changed/03."$filename" echo $filename changed | tee -a /home/[username]/Desktop/Changed/logfile done
As you may guess, this is the script for changing the names of the songs from CD 3. Remember to use your actual username. To make the scripts necessary for other CD’s simply change the 03 to whatever disc number you are interested in (01 or 02 or whatever). Put this into an empty file and save it. I saved mine as ChangeScript.sh (the sh file extension merely indictates it’s a shell script). Name yours whatever you want. (The line beginning echo is totally superfluous to the actions desired and so can be omitted, but it allows the script to tell you what it’s doing and so it can be very handy.) After you have saved this file you will want to alter the permissions of the file and allow execution:
- Right-click the .sh file you created and saved
- Choose Properties from the context menu which appears
- On the Properties dialog select the Permissions tab
- Check the “Allow executing file as program” box
Here is the setup I was using in which this script was functioning. I had a folder on my Desktop for each disc number (01-08) and after a disc would rip I would drop all the files for that disc into the appropriate folder. I had a copy of the script in each folder (each using the corresponding disc number 01-08). Open a command prompt (Applications —> Accessories —> Terminal) and get to the folder where you plan to do this work—I used my Desktop (enter: cd ~Desktop).
In a command prompt after dropping all the files for a disc into the correct folder I would perform the following actions to get into that folder and run the script (you won’t need the ../ the first time):
- cd ../01
This would put all of the files into another folder on my Desktop which I called Changed. (It also creates a logfile in Changed in case that interests you.) Once I had changed all the discs for a set I would move the files from Changed into my library. Then I would move on to the next set.
Totally confusing? You’ll get there. Hang on tight.
Hope this has been helpful.