Skip to content

Instantly share code, notes, and snippets.

@burntcookie90
Created December 22, 2014 19:35
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 burntcookie90/f3dfac7200eedc38d7d8 to your computer and use it in GitHub Desktop.
Save burntcookie90/f3dfac7200eedc38d7d8 to your computer and use it in GitHub Desktop.
#! /bin/sh
for a in *.flac; do
OUTF=${a%.flac}.mp3
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`
flac -c -d "$a" | lame --noreplaygain -V0 \
--add-id3v2 --pad-id3v2 --ignore-tag-errors --tt "$TITLE" --tn "${TRACKNUMBER:-0}" \
--ta "$ARTIST" --tl "$ALBUM" --ty "$DATE" --tg "${GENRE:-12}" \
- "$OUTF"
RESULT=$?
if [ "$1" ] && [ "$1" = "-d" ] && [ $RESULT -eq 0 ]; then
rm "$a"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment