Converting WAV to MP3 using LAME and Automator

Automator 'hangs' when attempting to use LAME encoder unfortunately. It's also not efficient or advisable to try and use a multi-threaded process as an Automator Service. For tasks such as this it's best to either run a simple script or use an alternate method.

The script below will encode a 20Mb .wav to .mp3 in 3 seconds! (at the highest quality settings)

file="$1"

find . -name '*.wav' -maxdepth 1 -exec /usr/local/bin/lame -V 0 -q 0 '{}' \;

for file in *.mp3
do
  mv "$file" "${file/wav./}"
done

To install, download, then open terminal:

sudo install encode-mp3 /usr/local/bin

To use, navigate into a desired conversion folder and type:

encode-mp3

This will encode your .wav files to .mp3

Convert .wav to .mp3 | LAME Encoder Shell Script [md5: 72d4e24f14ea9139136900f2c4281a7f]


[original]

I just wrote a one-liner that will do this for you in Terminal, just cd to the directory of files you want to convert and enter:

find ./ -name "*.wav" -execdir lame -V 3 -q 0 {} \;

You can use the following in Automator's "Run Shell Script" action (make sure to change "Pass input" to "as arguments"):

find "$1" -name "*.wav" -execdir /usr/local/bin/lame -V 0 -q 0 {} \;

This will find all .wav files in the selected folder, including sub-folders (and skip over any non-wav files). If you don't want it to look into sub-folders, you can change it to this:

find "$1" -name "*.wav" -maxdepth 1 -execdir /usr/local/bin/lame -V 0 -q 0 {} \;

Of course, you would change -V 0 -q 0 to whatever lame options you prefer.

If you want to be notified when it's done, you can add a say command, use a "Show Growl Notification" action (if you have Growl installed), or use a beep command in a "Run AppleScript" action.

Below is a screenshot of what my workflow looks like with the extra say command and the Growl notification. Also notice I changed the "Service receives selected" option at the top to "folders" (it will be "text" by default).

Lame WAV to MP3 Batch Conversion


The thread is a bit updated, but for those who may find it useful,

I used Automator setup described here, and was able to avoid getting it stuck with -S option of lame, so my "Run Shell Script" command looks like:

    find "$1" -name "*.wav" -maxdepth 1 -execdir /usr/bin/lame -b 160 -q 0 -S {} \;

(besides, my lame exec is in another place)

The -S option turns off Lames progress report