-
-
Save ssstonebraker/9444437 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
if [ "$1" ] | |
then | |
find "$1" -name '*.flac' | while read fn; | |
do | |
basename=$(basename "$fn" .flac).mp3 | |
dirname=$(dirname "$fn") | |
outfile="$dirname/$basename" | |
if [ -e "$fn" ] && [ ! -e "$outfile" ]; | |
then | |
id3title=$(metaflac --show-tag=TITLE "$fn" | perl -pe "s/^TITLE=(.*)/\$1/i") | |
id3artist=$(metaflac --show-tag=ARTIST "$fn" | perl -pe "s/^ARTIST=(.*)/\$1/i") | |
id3album=$(metaflac --show-tag=ALBUM "$fn" | perl -pe "s/^ALBUM=(.*)/\$1/i") | |
id3date=$(metaflac --show-tag=DATE "$fn" | perl -pe "s/^DATE=(.*)/\$1/i") | |
id3tracknumber=$(metaflac --show-tag=TRACKNUMBER "$fn" | perl -pe "s/^TRACKNUMBER=(.*)/\$1/i") | |
id3genre=$(metaflac --show-tag=GENRE "$fn" | perl -pe "s/^GENRE=(.*)/\$1/i") | |
flac -c -d "$fn" | \ | |
lame -h -m s -b 360 \ | |
--tt "$id3title" \ | |
--ta "$id3artist" \ | |
--tl "$id3album" \ | |
--ty "$id3date" \ | |
--tn "$id3tracknumber" \ | |
--tg "$id3genre" \ | |
- "$outfile" | |
else | |
echo >&2 ""$fn" -- skipping." | |
fi | |
done | |
else | |
echo >&2 "Usage: "$(basename "$0")" DIRNAME" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment