Converting FLAC to MP3
I’ve been looking for a decent way to convert FLAC files to MP3 under Linux for a while now. I’d been using SoundConverter, but I notice that there’s something not right with it. I’ll set my preference to VBR, highest quality (target rate is ~256), but I end up with files at around 150-192, which is not right.
So, I’ve done a bunch of searching around and have cobbled together this script, taking a little bit from here and a lot from there:
##START SCRIPT##
#!/bin/shfor a in *.flac
do
OUTF=`echo "$a" | sed s/"\.flac$"/"\.mp3"/g`ARTIST=`metaflac "$a" --show-tag=ARTIST | sed s/.*=//g`
TITLE=`metaflac "$a" --show-tag=TITLE | sed s/.*=//g`
ALBUM=`metaflac "$a" --show-tag=ALBUM | sed s/.*=//g`
GENRE=`metaflac "$a" --show-tag=GENRE | sed s/.*=//g`
TRACKNUMBER=`metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g`
DATE=`metaflac "$a" --show-tag=DATE | sed s/.*=//g`flac -c -d "$a" | lame -V 0 - "$OUTF"
id3v2 -t "$TITLE" -T "$TRACKNUMBER" -a "$ARTIST" -A "$ALBUM" -g "$GENRE" -y "$DATE" "$OUTF"
donemkdir "$ARTIST" && mkdir "$ARTIST"/"$ALBUM"
mv *.mp3 "$ARTIST"/"$ALBUM"/.
## END SCRIPT##
It works beautifully.
Tags: audio, conversion, files, flac, lame, Linux, mp3, Music, Ubuntu



January 17th, 2009 at 8:15 pm
Just tried your script and it works great. Just what I was looking for to replace SoundConvertor.
February 16th, 2009 at 1:15 pm
I want download metaflac for linux, and put it with this sh file (same directory), then have some errors : Can not run metaflac, i’m not good about Linux, can you help me this pro . Thank you very much