Created
February 10, 2012 22:43
-
-
Save SavinaRoja/1793660 to your computer and use it in GitHub Desktop.
How I convert my FLAC to mp3 in linux
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/bash | |
# Converts all flac files in a folder into mp3s, plus the id3 tag | |
# Requires flac, metaflac, lame, id3v2 | |
for a in * | |
do | |
# Check the file is a flac file | |
if [[ "$a" =~ flac$ ]] | |
then | |
# Name of outfile | |
OUTF=`echo "$a" | sed s/\.flac/.mp3/g` | |
echo "$a => $OUTF" | |
# Capture all the FLAC metadata | |
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` | |
# Convert the audio data from FLAC to MP3 | |
flac -c -d "$a" | lame -m j -b 256 -s 44.1 - "$OUTF" | |
# Tag the resulting MP3 with the captured metadata | |
id3v2 -t "$TITLE" -T "$TRACKNUMBER" -a "$ARTIST" -A "$ALBUM" -g "$GENRE" "$OUTF" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment