1

I have multiple .wav files (numbered from 1) which I want to convert them to .mp3. audacity can do that with opening a file and exporting using it's GUI.

Is there a way that I do this with a bash command so I can do the whole job with a bash loop?

2
0

Assuming you have the codecs installed (libavcodec52 or similar), and ffmpeg, something like this should work:

for i in `ls /my/wav/dir/*.wav`; do ffmpeg -i $i -acodec libmp3lame `basename $i .wav`.mp3; done

I always like to test crazy loops first to make sure the syntax is coming out right:

for i in `ls /my/wav/dir/*.wav`; do echo "ffmpeg -i $i -acodec libmp3lame `basename $i .wav`.mp3"; done
1
  • This works if the filenames do not contain spaces. – reinierpost Jan 24 '17 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.