Skip to content

Instantly share code, notes, and snippets.

@hjst
Created February 12, 2012 07: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 hjst/1807080 to your computer and use it in GitHub Desktop.
Save hjst/1807080 to your computer and use it in GitHub Desktop.
My flac2mp3 script adapted from one found in AUR
#!/bin/bash
# Usage:
# cd ~/Music/path/to/album/dir
# flac2mp3 /path/to/output/dir
find -name "*.flac" -print0 | while read -d $'\0' IF
do
OF=`echo "$IF" | sed s/\.flac$/.mp3/g | sed s,"$1","$2",g`
echo "$IF" "->" "$1/$OF"
mkdir -p "$1"
ARTIST=`metaflac "$IF" --show-tag=ARTIST | sed s/.*=//g`
TITLE=`metaflac "$IF" --show-tag=TITLE | sed s/.*=//g`
ALBUM=`metaflac "$IF" --show-tag=ALBUM | sed s/.*=//g`
GENRE=`metaflac "$IF" --show-tag=GENRE | sed s/.*=//g`
TRACKNUMBER=`metaflac "$IF" --show-tag=TRACKNUMBER | sed s/.*=//g`
DATE=`metaflac "$IF" --show-tag=DATE | sed s/.*=//g`
flac -c -d "$IF" 2> /dev/null | lame \
--add-id3v2 --pad-id3v2 --ignore-tag-errors --tt "$TITLE" --tn "${TRACKNUMBER:-0}" \
--ta "$ARTIST" --tl "$ALBUM" --ty "$DATE" --tg "${GENRE:-12}" \
-V 0 - "$1/$OF" 2> /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment