Skip to content

Instantly share code, notes, and snippets.

@fbentele
Created September 24, 2014 17:43
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 fbentele/7e91768250392f72862f to your computer and use it in GitHub Desktop.
Save fbentele/7e91768250392f72862f to your computer and use it in GitHub Desktop.
Flac2mp3
#!/bin/bash
# by K-Soft! 05/24/2012 with parts from
# http://bash.cyberciti.biz/multimedia/linux-unix-bsd-convert-flac-to-mp3/
# convert flac to mp3 and writes id3 tags
# usage: flactomp3 /path/to/my/awesome/music/
# requires FLAC, ID3, LAME
# change quality -V 0-9
IFS=$'\t'
if [ $# -eq 0 ] ; then
echo 'No arguments provided, usage: flactomp3 /my/awesome/music/'
exit 0
fi
for flacfile in $1*.flac
do
outf=${flacfile%.flac}.mp3
eval "$(
metaflac "$flacfile" --show-tag=ARTIST \
--show-tag=TITLE \
--show-tag=ALBUM \
--show-tag=GENRE \
--show-tag=TRACKNUMBER \
--show-tag=DATE | sed 's/=\(.*\)/="\1"/'
)"
flac -c -d "$flacfile" | lame -m j -q 0 --vbr-new -V 0 -s 44.1 - "$outf"
id3 -t "$TITLE" -T "${TRACKNUMBER:-0}" -a "$ARTIST" -A "$ALBUM" -y "$DATE" -g "${GENRE:-12}" "$outf"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment