Skip to content

Instantly share code, notes, and snippets.

@luisuribe
Created February 12, 2014 15:22
Show Gist options
  • Save luisuribe/8957488 to your computer and use it in GitHub Desktop.
Save luisuribe/8957488 to your computer and use it in GitHub Desktop.
flac to mp3 with tags
for a in *.flac; do
# give output correct extension
OUTF="${a[@]/%flac/mp3}"
# get the tags
ARTIST=$(metaflac "$a" --show-tag=ARTIST | sed s/.*=//g)
TITLE=$(metaflac "$a" --show-tag=TITLE | sed s/.*=//g)
ALBUM=$(metaflac "$a" --show-tag=ALBUM | sed s/.*=//g)
GENRE=$(metaflac "$a" --show-tag=GENRE | sed s/.*=//g)
TRACKNUMBER=$(metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g)
DATE=$(metaflac "$a" --show-tag=DATE | sed s/.*=//g)
# stream flac into the lame encoder
flac -c -d "$a" | lame -V0 --add-id3v2 --pad-id3v2 --ignore-tag-errors \
--ta "$ARTIST" --tt "$TITLE" --tl "$ALBUM" --tg "${GENRE:-12}" \
--tn "${TRACKNUMBER:-0}" --ty "$DATE" - "$OUTF"
done
# from https://wiki.archlinux.org/index.php/Convert_Flac_to_Mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment