Simple FLAC to MP3 shell script

By , 2009-09-10 21:41

For unix-like systems (Mac OS X, Linux). A simple shell script to convert flac to lame mp3.

Install flac, lame and id3tool

#!/bin/bash
for a in *.flac
do
OUTLAME=`echo "$a" | sed s/\.flac$/.mp3/g`
ARTIST=`metaflac "$a" --show-tag=ARTIST | sed s/.*=//g`
ALBUM=`metaflac "$a" --show-tag=ALBUM | sed s/.*=//g`
TITLE=`metaflac "$a" --show-tag=TITLE | sed s/.*=//g`
GENRE=`metaflac "$a" --show-tag=GENRE | sed s/.*=//g`
TRACKNUMBER=`metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g`
YEAR=`metaflac "$a" --show-tag=DATE | sed s/.*=//g`
flac -c -d "$a" | lame -m j -q 0 --vbr-new -V 0 -s 44.1 - "$OUTLAME"
id3tool --set-title="$TITLE" --set-track="${TRACKNUMBER:-0}" --set-artist="$ARTIST" --set-album="$ALBUM" --set-year="$YEAR" --set-genre="${GENRE:-12}" "$OUTLAME"
done

Edit: Apparently this has been done before…
http://pastebin.com/f641a9b21

One Response to “Simple FLAC to MP3 shell script”

  1. aimkeepachieve says:
    Firefox 37.0 Firefox 37.0 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0

    I use iDealshare VideoGo to convert FLAC to MP3, M4A, WAV, AIFF, AAC on My Mac OS X computer, in fact it also has Windows version.

    It even can convert video or audio files to FLAC.

    It also has editing features like adjust audio volume, channel, bitrates, etc.

Leave a Reply

 

Custom theme by me. Based on Panorama by Themocracy