Skip to content

Instantly share code, notes, and snippets.

@abits
Created February 16, 2014 21:51
Show Gist options
  • Save abits/9041153 to your computer and use it in GitHub Desktop.
Save abits/9041153 to your computer and use it in GitHub Desktop.
flac to mp3
#!/bin/bash
shnsplit -o flac -f *.cue *.flac
cuetag.sh *.cue split*.flac
for a in split*.flac; do
# give output correcit 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 -h -V2 --vbr-new -q0 --lowpass 19.7 -b96 --add-id3v2 --pad-id3v2 --ignore-tag-errors \
--ta "$ARTIST" --tt "$TITLE" --tl "$ALBUM" --tg "${GENRE:-12}" \
--tn "${TRACKNUMBER:-0}" --ty "$DATE" - "$OUTF"
done
mkdir mp3
mv split*.mp3 mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment