r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

How To: Convert a Directory of MP3s to WAVs in Linux

r3dux | November 10, 2009

I went to burn a couple of audio CDs for the boy today, and bod-frickn-dammit if Brasero / GnomeBaker and K3B didn’t all threw their hands in the air in dismay that I might actually have the nerve to want to convert mp3s to CD-audio on the fly. Very poor.

So, as wav files come in less flavours than mp3s and tend to work first time, I knocked up a quick script to convert a directory of mp3s to .wav files using mpg123, it even handles spaces correctly after I’d given it a stern talking to… Anyways:

#/bin/bash
gotmpg123=$(which mpg123)
 
# If there's no copy of mpg123 we're not going to be doing any converting. Abort!
if [ "$gotmpg123" = "" ]; then
    echo "No copy of mpg123 found on system! Try running: sudo apt-get install mpg123"
    exit 0
fi
 
# Otherwise, if we're all set, make a directory to dump our wav files into
mkdir WAV
 
# For each file in the current directory that ends with .mp3, convert it to .wav and place in our new WAV folder
for file in ./*.mp3
do
  mpg123 -w ./WAV/"${file}".wav "$file"
done

To use the script:
- Copy and paste the above code into a new text file called mp32wav or something
- Make it executable with chmod +x mp32wav, then
- Copy it to /usr/local/bin for easy access with sudo cp mp32wav /usr/local/bin/

With that all done you can just go into a folder of mp3s in the terminal and fire it off. It’ll create a folder called WAV inside whatever directory you’re in and stick the converted wav files there with the original filename but with .wav tacked on the end.

Cheers!

Comments
2 Comments »
Categories
Coding, How-To, Linux, Music
Tags
Bash, Convert, Linux, mp3, mp32wav, mpg123, script, wav
Comments rss Comments rss
Trackback Trackback

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Convert CS4 Effect Film Flash GLSL Gnome Hack How-To install Jaunty Java Kinect Linkage Linux Mash-Up Microsoft Motion OpenGL Particle Photoshop Problem PS3 Remix Remove Retro script Slides Sound Systems Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“Dreams do not vanish, so long as people do not abandon them.”

 - Phantom F. Harlock

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox