Created
June 29, 2019 16:13
-
-
Save micahjsmith/a1cec30036f8c14d8987e768ca8a1530 to your computer and use it in GitHub Desktop.
convert flac to mp3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# convert flac to mp3 | |
# source: @Jake Plimack/@boehj https://apple.stackexchange.com/a/293421 | |
# usage: | |
# find <dir> -name '*flac' -print0 | xargs -0 -P8 -n1 flac2mp3 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment