Sunday, March 8, 2009

Convert wav to mp3 for a directory [Linux Hacks]

There are some really nice Linux tools out there to do wav to mp3 conversion (lame, bladeenc etc). Here is a small shell script to run on a given directory that will convert all .wav files to .mp3:

wav2mp3.sh

Output:


$ ./wav2mp3.sh /home/nmaxwell/foo/
/usr/bin/bladeenc
Performing mp3 conversion on: /home/nmaxwell/foo/
Old filename: /home/nmaxwell/foo/song.wav
New filename: /home/nmaxwell/foo/song.mp3

BladeEnc 0.94.2 (c) Tord Jansson Homepage: http://bladeenc.mp3.no
===============================================================================
BladeEnc is free software, distributed under the Lesser General Public License.
See the file COPYING, BladeEnc's homepage or www.fsf.org for more details.

Files to encode: 1

Encoding: /home/nmaxwell/foo/song.wav
Input: 44.1 kHz, 16 bit, stereo.
Output: 128 kBit, stereo.

Completed. Encoding time: 00:00:07 (21.71X)

All operations completed. Total encoding time: 00:00:07


The script will run this conversion on any files it sees in the directory with the .wav extension.

No comments:

Post a Comment