simple directory mass lame decode

Categories: Misc, OS

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

  • 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:
    `echo $x | cut -d. -f1`.mp3 equals $x

    `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

Leave a Reply

Your email address will not be published. Required fields are marked *