flac to mp3

John L Fjellstad john-ubuntu at fjellstad.org
Tue Mar 6 05:28:49 UTC 2007


Paul Kaplan <pkaplan1 at comcast.net> writes:

> Any recommendations for a program to convert a bunch of flac audio
> files to mp3 format?

This is the script I use:
#!/bin/bash

METAFLAC=/usr/bin/metaflac
LAME=/usr/bin/lame
LAME_OPTS="--preset extreme --add-id3v2 --ignore-tag-errors"
FLAC=/usr/bin/flac

function usage
{
        echo $0 flac1 [flac2] [flac3] ...
        exit 1
}

if [ $# -lt 1 ]; then
        usage
fi


for file in "$@"; do
file "$file" | grep FLAC
if [ $? -eq 0 ]; then
        ARTIST=`metaflac --show-tag=ARTIST "$file" | cut -d'=' -f2`
        ALBUM=`metaflac --show-tag=ALBUM "$file" | cut -d'=' -f2`
        TITLE=`metaflac --show-tag=TITLE "$file" | cut -d'=' -f2`
        DATE=`metaflac --show-tag=DATE "$file" | cut -d'=' -f2`
        GENRE=`metaflac --show-tag=GENRE "$file" | cut -d'=' -f2`
        TRACK=`metaflac --show-tag=TRACKNUMBER "$file" | cut -d'=' -f2`
        mp3file=`basename "$file" flac`
        flac -d -c "$file" | lame $LAME_OPTS --tt "$TITLE" --ta "$ARTIST" --tl "$ALBUM" --ty "$DATE" --tn "$TRACK" --tg "$GENRE" - "${mp3file}mp3"
fi
done
exit 0

Probably someone who can optimize the script

-- 
John L. Fjellstad
web: http://www.fjellstad.org/          Quis custodiet ipsos custodes





More information about the kubuntu-users mailing list