Skip to content

Instantly share code, notes, and snippets.

@klynch
Created October 1, 2013 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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
@techstalks
Copy link

what is this code? applescript? how to do that? please tell me the steps. :)

@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