How to batch convert .ogg files to .wav using a command line utility?

7.8k Views Asked by At

I have a bunch of files:

dir/file1.ogg
dir/file2.ogg
...

How could I convert them to .wav files

dir/wav/file1.wav
dir/wav/file2.wav
...

by using a console command? Now I'm using OSX, but I need the answer for Windows as well.

1

There are 1 best solutions below

2
On BEST ANSWER

Your sample code is close.

for i in *.ogg; do
  ffmpeg -acodec libvorbis -i "$i" -acodec pcm_s16le "${i%ogg}wav"
done

This decodes with ffmpeg and generates an output file name that removes the trailing ogg and appends a trailing wav.