Sun Jun 25 17:36:53 CEST 2006

Compiling an MP3 CD for the car

We bought a new car yesterday, and it's all white and pretty. And it's got an MP3 player. So we now have to burn MP3 files onto a CD, is life hard or what?

So, I already use jack to automate ripping. It works really well and is easy to use (basically you just need to type in 'jack -q' and get the resulting files in ~/jack 20 minutes later).

Now, one problem is that CDDB filenames tend to have many spaces, and I worry the MP3 reader won't like that. So here we shall clean up all the filenames:

rename 's/-//g' *            # remove dashes
rename 's/\.(?!...$)//g' *   # remove dots that aren't for the extension
rename 's/ //g' *            # remove spaces
rename 's/^.*?(\d)/$1/' *    # remove band and album name
rename is an absolutely brilliant tool for this sort of stuff...

I'll then need to convert everything from ogg (my storage format of choice) to MP3:

find . -name "*.ogg" | xargs oggdec   # Decode all to .wav
find . -name "*.wav"  -exec lame {} {}.mp3 \;  # encode all to .mp3
# Move the mp3's somewhere else:
cd /tmp
find /path/to/mp3s -name "*.mp3" | xargs tar cf - | tar xf -
# Remove the .wav from filenames
for i in *; do (cd $i; rename 's/\.wav//' *); done

We're now ready to burn, baby, burn!

mkisofs -J -o out.iso .
cdrecord dev=/dev/cdrom -eject out.iso
And voila, we're finally done. I'll have to check whether renaming the files really is useful (and thus potentially sacrifice a blank CD...)