Skip to content

Instantly share code, notes, and snippets.

@adriancb
Created January 13, 2015 15:19
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 adriancb/82eb09c6c94c6a58222b to your computer and use it in GitHub Desktop.
Save adriancb/82eb09c6c94c6a58222b to your computer and use it in GitHub Desktop.
FLAC to MP3
#!/bin/bash
for f in "$@"; do
[[ "$f" != *.flac ]] && continue
album="$(metaflac --show-tag=album "$f" | sed 's/[^=]*=//')"
artist="$(metaflac --show-tag=artist "$f" | sed 's/[^=]*=//')"
date="$(metaflac --show-tag=date "$f" | sed 's/[^=]*=//')"
title="$(metaflac --show-tag=title "$f" | sed 's/[^=]*=//')"
year="$(metaflac --show-tag=date "$f" | sed 's/[^=]*=//')"
genre="$(metaflac --show-tag=genre "$f" | sed 's/[^=]*=//')"
tracknumber="$(metaflac --show-tag=tracknumber "$f" | sed 's/[^=]*=//')"
flac --decode --stdout "$f" | lame --preset extreme --add-id3v2 --tt "$title" --ta "$artist" --tl "$album" --ty "$year" --tn "$tracknumber" --tg "$genre" - "${f%.flac}.mp3"
done
# steps...
# brew install flac lame
# save this file somewhere...
# run the below...
# find . -name '*.flac' -exec convert.sh {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment