Skip to content

Dumping a bunch of MP3s as WAV files

I just used the following command for converting a directory with a bunch of MP3s to WAV. Does someone know a command that is shorter? I find mine a bit convoluted to say the least.

mkdir wav
ls *mp3|while read i; do  mpg123 --stdout "$i" > wav/`echo $i|sed -r -e 's/^([0-9]+) .*$/\1/'`.wav; done

The directory looks like this:

$ ls -1
01 - Meant to Be.mp3
02 - Reflections.mp3
03 - Semester Days.mp3
04 - Friend.mp3
05 - True Gemini.mp3
06 - Down the Road.mp3
07 - Tulip Trees.mp3
08 - Not Alone.mp3
09 - Woods of Chaos.mp3
10 - Twilight.mp3
[en] Readme - www.jamendo.com .txt
[es] Lee me - www.jamendo.com .txt
[fr] Lisez moi - www.jamendo.com .txt
[it] Readme - www.jamendo.com .txt
License.txt
Rob Costlow - Solo Piano - Woods of Chaos.1.0.jpg

    1 Comment ( Add comment / trackback )

    1. (permalink)
      Comment by halfgaar
      On December 9, 2009 at 13:19

      This is what I would do:

      for mp3_file in *.mp3; do mpg123 -w "`echo $mp3_file|sed -e 's/mp3/wav/'`" "$mp3_file"; done

      Although it’s hardly shorter…