Note that you will need flac and lame for this to work. Run the following line in the directory where the flac files are:
for file in *.flac; do flac -cd “$file” | lame -h – “${file%.flac}.mp3″; done
You can also make lame create the mp3 files somewhere else. Take the following line:
for file in *.flac; do flac -cd “$file” | lame -h – YOURLOCATION/”${file%.flac}.mp3″; done
A little bash (with some extra features such as preversing the meta tags)
#!/bin/bash if $# -ne 1 then echo "Usage: `basename $0` sourcePath" exit 65 fi SOURCEPATH=${1%/} TARGETPATH=${1%/}.mp3 FINDEXT=".flac" IFS=$'^' TEMPIMAGE=${1%/}.mp3/${1%/}.jpg echo "Ready to convert all flac in source path $SOURCEPATH to mp3 in target path $TARGETPATH" echo "Do you want to continue ? (y/n)" read ans $ans != "y" && sleep 2 && exit 0 find $SOURCEPATH -type d -exec mkdir -p $TARGETPATH/{} \; find $SOURCEPATH -type f -name *$FINDEXT | while read file do ARTIST=$(metaflac "$file" --show-tag=ARTIST | sed s/.*=//g) TITLE=$(metaflac "$file" --show-tag=TITLE | sed s/.*=//g) ALBUM=$(metaflac "$file" --show-tag=ALBUM | sed s/.*=//g) GENRE=$(metaflac "$file" --show-tag=GENRE | sed s/.*=//g) TRACKNUMBER=$(metaflac "$file" --show-tag=TRACKNUMBER | sed s/.*=//g) DATE=$(metaflac "$file" --show-tag=DATE | sed s/.*=//g | cut -d "-" -f 1) metaflac "$file" --export-picture-to=${TEMPIMAGE} outputFile="$TARGETPATH/${file%.flac}.mp3" flac -cd "$file" | lame -h -b 192 - $outputFile /usr/local/bin/eyeD3 -t "$TITLE" -n "${TRACKNUMBER:-0}" -a "$ARTIST" -A "$ALBUM"add-image ${TEMPIMAGE}:FRONT_COVERencoding utf16remove-allto-v2.3 "$outputFile" #fixes Date and Genre (buggy in eyeD3) id3v2 -2 -y "$DATE" -g "${GENRE:-12}" "$outputFile" rm ${TEMPIMAGE} done