command-lineffmpegterminaldata-conversionafconvert

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


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.


Solution

  • 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.