Batch convert wav to mp3 with ffmpeg

less than 1 minute read

Familiar with Linux OS, using ffmpeg
Batch convert wav under the directory to mp3.

I will also show you how to prevent the converted file name from becoming .wav.mp3.

environment

  • mac OS : Catalina version 10.15.6
  • ffmpeg : stable 4.3.1 (bottled)

General conversion

For one file conversion, you can do it with:

$ ffmpeg -i input.wav ouput.mp3

Batch conversion

If you want to convert files under the directory at once, you can convert them by the following methods.

$ for f in *.wav ; do ffmpeg -i $f ${f%.wav}.mp3 ; done;

By the way, by giving it as $ {f% .wav} instead of $ f.wav
It can be converted to an mp3 file excluding the .wav part.

.
.
.

I was able to convert the file, but for those who are in trouble because it becomes .wav.mp3
I hope it helps.