问题描述:

I'm making an iPhone app and I have a ton of .wav files I need to convert to .caf

I can use this for each file:

afconvert -f caff -d [email protected] walking.wav walking.caf

But that would take ages, so I'm trying to convert all files with:

for i in *.wav; do afconvert -f -caff -d [email protected] -c 1 $i ${i%.wav}.caf; done

But I get this error:

Error: ExtAudioFileCreateWithURL failed ('typ?')

EDIT:The error will actually occur because of a typo in the for loop shown above. It should be caff not -caff. The correct code snippet would then be.

for i in *.wav; do afconvert -f caff -d [email protected] -c 1 $i ${i%.wav}.caf; done

There may be other issues and the accepted answer is valid, just wanted to help out with making the question clear. /EDIT

网友答案:

This is the script i have been using, slightly modified from another source, which kindly deserves all credit:

##
## Shell script to batch convert all files in a directory to caf sound format for iPhone
## Place this shell script a directory with sound files and run it: 'sh afconvert_wavtocaf.sh'
## Any comments to '[email protected]'
##

for f in *.wav; do
if  [ "$f" != "afconvert_wavtocaf.sh" ]
then
 afconvert -f caff -d ima4 $f
 echo "$f converted"
fi
done

Save this in a file named 'afconvert_wavtocaf.sh'. See if that does the trick.

网友答案:

Try adding echo $i; before afconvert in your script to get the name of sound file your command fails on. Then try to convert it manually, it will probably fail too.

I suspect one of your files is not an actual wav, but is in format not recognizable by afconvert.

相关阅读:
Top