How to Batch Convert FLAC files to MP3

By | June 25, 2015

FLAC files are a audio files that retain 100% of their original data. They are great for storing archive copies of CD’s.

flac-logo

If you have FLAC files and want to play them on an MP3 player that doesn’t support the FLAC file format then you’ll need to convert them down to MP3 files.

Every once in a while I need to convert an entire directory of FLAC files to MP3. The FLAC decoder does a great job of handling lots of files in a directory, but the LAME encoder can’t seem to wrap it’s mind around the concept of “do this to all my files”. With a little batch file we can make LAME handle an entire directory.

Here is a quick way to convert an entire directory of files from FLAC to MP3.

Prerequisits

  • This guide is for Windows.
  • You need to have both flac.exe and lame.exe available on your computer.
  • I keep my binaries like these in c:\bin and I take that directory with me whenever I reinstall Windows.
  • This guide assumes that the files you want to encode are located in c:\temp.

Convert FLAC Files to WAV

We’re going to first convert the entire directory to WAV. We’ll do this using the FLAC decoder.

  1. Open up a command prompt.
  2. Navigate to the directory that has flac.exe in it (for me, it’s c:\bin, so I type cd \bin)
  3. Run this command: (Don’t forget the star near the end, inside the quotes.)

That should run the FLAC decoder on all files in c:\path\to\music. When it’s done all of your original files will be there, and there will copies of them with a WAV extension. They’ll also be 2-4x larger than their equivalent FLAC files. Now that we have WAV files we can convert them to MP3 files with LAME.

Convert WAV Files to FLAC

This is where it gets a little more challenging. The LAME mp3 encoder does not support * wildcards to encode all files in a directory. It acts like it does, but it only encodes the first file it finds then it exits.

To work around this limitation well use a simple batch file. We’ll create it with notepad like this:

  1. Open up a command prompt.
  2. Navigate to the directory that has the WAV files in it (for me, it’s c:\temp, so I type cd \temp)
  3. Create a batch file called “go.bat” with notepad like this:
  4. Put the following line in go.bat: (Notice this refers to c:\bin which is where I have lame.exe located.)
  5. Save the batch file and exit notepad
  6. Run the batch file by typing go and pressing the enter key.

This should run the LAME encoder on each WAV file that is located in the same directory as the batch file, and encode it with the medium preset, which is good enough for most people. If you want higher audio quality you can change the medium preset to either “standard”, “extreme”, or “insane”.

Now that we are done with the WAV files you can delete them.

One thought on “How to Batch Convert FLAC files to MP3

  1. Raj

    dear Jason
    your posting is excellent.
    i wanna thank you for this excellent tricks.

    regards,
    Raj

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *