Convert a flac file into an mp3 file

On Ubuntu, install flac.

#apt-get install flac lame

Put the following script in /usr/bin/ and give it a name ( or

[ -r "$FLAC" ] || { echo can not read file \"$FLAC\" >&1 ; exit 1 ; } ;
metaflac --export-tags-to=- "$FLAC" | sed 's/=\(.*\)/="\1"/' >tmp.tmp
cat tmp.tmp
. ./tmp.tmp
rm tmp.tmp
flac -dc "$FLAC" | lame --tt "$TITLE" \
--tn "$TrackNumber" \
--tg "$GENRE" \
--ty "$Date" \
--tc "$COMMENT" \
--ta "$ARTIST" \
--tl "$ALBUM" \
--add-id3v2 \
- "$MP3"

change the execution bit

$ chmod 755 /usr/bin/

You can run it in a loop

for i in *.flac
do $i

Leave a Reply

Your email address will not be published.