2009
06.16

simple directory mass lame decode

need to convert all the mp3’s in a directory to wave to burn in xcdroast ?

here is an easy way:
for x in *mp3 ; do lame --decode `echo $x | cut -d. -f1`.mp3 `echo $x | cut -d. -f1`.wav ; done

obviously this assumes you have lame installed

EDIT 06.17.09 – converting wma to mp3’s (found this using “the google”, not mine):
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i" && lame -m j -h --vbr-new -b 160 audiodump.wav -o "`basename "$i" .wma`.mp3"; done; rm -f audiodump.wav
this assumes you have mplayer & lame

1 comment so far

Add Your Comment
  1. OK, but why make it so complex?
    BTW that won’t work if your file names contain dots, because cut will take the first part only. Same with whitespace, because bash will split filename containing spaces into several parameters. Surround with “” to prevent that. As to the complexities:
    First:
    `echo $x | cut -d. -f1`.mp3 equals $x

    Second:
    `echo $x | cut -d. -f1`.wav ==
    `cut -d. -f1 <<< $x`.wav ==
    ${x%mp3}wav – this is pure bash, no external programs.

    So finally:
    for f in *mp3; do lame –decode "$f" "${f%mp3}wav"; done