After getting a new mp3-player (the iAudio D2 from COWON) I wanted to find a quick and easy way of “tagging” and converting a number of albums that I had in flac-format (or mp3) into mp3 of a certain bitrate. My goal was to just browse through my collection, and touch a file inside a directory if I wanted to convert it. When I was done with the touching, I’d just fire up a small script that did all the work for me, while I was doing something else. Here’s what I came up with.

I previously had a small script that accepted one or more flac-files as arguments, and converted them to mp3. I used that as a basis for my flac-conversion, and added a simple mp3-conversion (or copying) and wrapped the whole thing in a loop based on the file I touched in order to do everything automatically.

I also made an extremely simply script for quick touching of a file in the current directory, which I called ct.

I’d browse through my collection of music in something like gnome-commander, and simply type ‘ct’ in a directory I wanted to convert.

After all directories are tagged, it’s time to start the work. This script was called batch2mp3.

Obviously you want to change the SOURCEDIR and DESTDIR settings, and maybe also the COPYMP3 setting. The script is fairly easy, so I won’t go into any detail on how it works. If you find a use for this, please drop me a comment.

I recently edited this post to add links to the various scripts instead, as I realized posting code directly in the article wasn’t really optimal. As an added bonus, here’s a third script I use (mostly when ripping my CD’s to flac) in order to rename the files to a “standard” format, with all lowercase, accented and some special characters removed, etc. It’s called fixMusicFilenames, but it will rename anything. So be warned. Don’t run it recursively as root, in /! ;-)