Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 789
Elliot Avatar asked Aug 13 '09 11:08

Elliot


4 Answers

Similar approach for bash: for i in *.wav; do afconvert -f caff -d LEI16@44100 -c 1 $i ${i%.wav}.caf; done

like image 91
Randall Avatar answered Oct 19 '22 17:10

Randall


On Windows, use the %~ni syntax.

for %i in (*.wav) do afconvert -f caff -d LEI16@44100 -c 1 %i %~ni.caf
like image 38
lavinio Avatar answered Oct 19 '22 18:10

lavinio


for file in *.wav; do afconvert -f caff -d LEI16@44100 -c 1 "$file"; done

Hit the Return key directly after done.

Simple :)

like image 5
AABSTRKT Avatar answered Oct 19 '22 19:10

AABSTRKT


For the people who are using OSX and are a bit afraid of Terminal scripts I created a little application with Automator, this application converts the files you select.

Download here

like image 5
Jankeesvw Avatar answered Oct 19 '22 17:10

Jankeesvw