Home Download Ubuntu

FLAC to MP3 script

The following script will decode the flac files in wav and then encode them in mp3.

1. First we install flac and lame library:

sudo apt-get install flac lame

2. Open a file:

sudo nano /bin/flac2mp3

3. You'll now need to make it executable:

sudo chmod +x /bin/flac2mp3

4. Paste the following script:

# Encode
# v0.1 17.08.08 - First created
# Darren O'Connor

# This script, when run in a folder full of FLAC files, will create high quality VBR mp3's for use in mp3 players.
# This version uses lame 3.98. If you use version 3.97 and below you'll need to change a few options

mkdir wav/
flac -d *.flac
mv *.wav wav/
cd wav/
for f in *.wav; do mv "$f" "${f%.wav}";done
mkdir ../mp3/
find -maxdepth 1 -type f -name '*' -exec lame -V0 -q0 '{}' -o '../mp3/{}' \;
cd ../mp3/
for FILE in *; do mv "$FILE" "$FILE.mp3"; done
cd ../
rm -r wav/

5. How to use:

we navigate to out directory containing .flac files and run

sudo flac2mp3

after everything was encoded, you will see a subdirectory called mp3. those are the files you need.

Resources: ubuntuforums


fitsum said...

Simple and straightforward.

Goonk said...

It works great!

gbp said...

Really Awesome!!!

Daniel Butler said...

Only problem is no tags!

Anonymous said...

Why not skip the intermediate .wav step, and pipe directly into lame? That'll save you from having to delete the WAVs afterwards, and lets you one-line the meat of it. e.g.:


for file in *.flac; do flac -d -c "$file" | lame -V0 -q0 - "`echo "$file" | sed -e s/"\.flac"/.mp3/g`"; done

mkdir flac
mv *.flac flac/

Post a Comment