command-lineaudiowavcafafconvert

How do I use afconvert to convert all the files in a directory from wav to caf?


I have a directory with about 50 wav files that I need to convert to caf, because AudioServicesCreateSystemSoundID() returns an error for some of them (but not all).

Here's an example of the command I've used successfully for a single file:

afconvert -f caff -d LEI16@44100 -c 1 whistle.wav whistle.caf

How do I do this quickly - not one-by-one for each file?


Solution

  • On Windows, use the %~ni syntax.

    for %i in (*.wav) do afconvert -f caff -d LEI16@44100 -c 1 %i %~ni.caf