• simfonik over 9 years ago

    I have a couple thousand .wav files I would like to convert to .mp3

    I've managed to compile LAME and can access it via the terminal to successfully convert a single file:

    $lame -b 320 -h input.wav output.mp3

    I need some help figuring out how to convert many files now. This is pretty easy going from .wav to .flac:

    $flac --best *wav

    That converts everything in the directory from .wav to .flac and retains the existing file names. I would love to be able to do just that going from .wav to .mp3

    Any help appreciated.
  • teo over 9 years ago

    You could do it with a shell script. I don't know the exact syntax offhand but the logic would go:

    for file in current_dir
    lame -b 320 -h $file $file.mp3
    end for
  • simfonik over 9 years ago

    simfonik edited over 9 years ago
    still stumbling around on this. i thought i had it with:

    for i in *.wav; do lame -b 320 -h ${i} ${i}.mp3; done

    i get this error message though: 'lame: excess arg Core'
  • simfonik over 9 years ago

    got it!! :D

    for i in *.wav; do lame -b 320 -h "${i}" "${i}.mp3"; done
  • the_electrician over 9 years ago

    well done! i might try that sometime...

    so you select the .wav directory as the current directory first then run that command?
  • simfonik over 9 years ago

    simfonik edited over 9 years ago
    exactly. i had all my .wav files in a folder on the desktop called "mp3convert" and just changed to that directory and ran the script. it worked like a charm.

    your files will then look like:

    filename.wav.mp3

    they'll be mp3 files, but you'll probably want to get rid of the .wav text from the file name. this will do that (thanks kevin!):

    ls *.wav.mp3 | sed 's/\(.*\)\.wav\.mp3/mv "\1.wav.mp3" "\1.mp3"/'|sh
  • teknosmoker over 9 years ago

    You can batch convert with XLD. Very versatile & supports a ton of formats too.

    It'll even let you batch process FLAC files directly to LAME MP3.

Log In You must be logged in to post.