flac2mp3

I was going through Fedora Planet stream when I noticed this blog post about converting Flac files to mp3 on Linux.   That reminded me of a couple of folders with files that I can’t listen to in my car.  So I thought I’d convert them now, especially that I have the guide handy it only consists of a couple of steps.  I tried and it worked, except that default options used resulted in the mp3 file of 128 kbps, which is a rather low quality.  So I played a bit with it and ended up with the following shell flac2mp3.sh script:

#!/bin/bash

# Convert flac file to mp3 with best quality VBR

for file in *.flac
do
    base=`basename "$file" .flac`
    # Convert flat to wav
    flac -d "$file"
    # Convert wav to mp3 with variable bit rate, best quality
    lame -V 0 "$base".wav "$base".mp3
done

As mentioned in the comments, it creates variable bit rate (VBR) mp3 files with maximum quality.

Update: The moment I finished this blog post I felt weird. It was almost like I did it before. And indeed. I should have searched my own blog before posting. Here is the post I did five years ago which has pretty much the same script in it.

Leave a Comment