Skip to content

Instantly share code, notes, and snippets.

@klynch
Created October 1, 2013 00:37
Show Gist options
  • Save klynch/6772392 to your computer and use it in GitHub Desktop.
Save klynch/6772392 to your computer and use it in GitHub Desktop.
An old script I found lying around to convert FLAC files to MP3
#!/bin/bash
lame_opts=" --vbr-new -V 2 -B 256 "
for x in "${@}"
do
FLAC=${x}
MP3="${FLAC%.flac}.mp3"
[ -r "$FLAC" ] || { echo can not read file \"$FLAC\" >&1 ; exit 1 ; } ;
metaflac --export-tags-to=- "$FLAC" | sed 's/=\(.*\)/="\1"/' > tmp.tmp
. ./tmp.tmp
rm tmp.tmp
echo "Converting ${FLAC} to MP3 format"
flac -c -d "$FLAC" | lame ${lame_opts} \
--tt "$TITLE" \
--tn "$TRACKNUMBER" \
--tg "$GENRE" \
--ty "$DATE" \
--tc "$COMMENT" \
--ta "$ARTIST" \
--tl "$ALBUM" \
--add-id3v2 \
- "$MP3"
done
@klynch
Copy link
Author

klynch commented Dec 14, 2013

It is a shell script. Just download and run it from a terminal like so "bash flac2mp3.sh file.flac". You will need to install flac and the lame encoder installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment