MacOS: How to convert CAF sound files to AIF, MP3, WAV, AU, etc.

Mac CAF/AIF/MP3 sound file FAQ: How do I convert a CAF file to AIF format, MP3 format, or any other sound file format on Mac OS X, for free?

Convert CAF to AIF, MP3, WAV, for free - solution

While writing my Mac “Hide Your Desktop” application, I can’t work with certain sound file formats yet, so I’ve been digging around trying to figure out how to convert Apple's “CAF” file format into a format I can deal with, and I really need files to be in an AIF, MP3, WAV, or AU format.

Last night I found a cool Mac OS X command-line utility named afconvert that lets you convert sound files from one format to another, for free. So I dug into it, and eventually created a shell script that lets me convert all my CAF sound files into AIF sound files. A slightly modified version of the same script will allow you to convert CAF or AIF sound files to MP3, WAV, and other sound file formats.

Caution: Back up your files

As the usual word of caution, make a backup copy of your files before using this script. I have only tested in on a small collection of files.

How to convert many CAF files to AIF, MP3, WAV, or AU

For my purposes, I know I can work with WAV, AU, and AIF files (AIFF, AIFC), so after a little testing, I created this script to convert every CAF sound file in the current directory into a corresponding AIF file:


# a script to convert every CAF sound file in the current
# directory to a corresponding AIF sound file.
# author: alvin alexander,
# This work is licensed under the Creative Commons Attribution-Share Alike 3.0 
# United States License:


# list all CAF files in the current directory.
# (the -1 character in this line is a "one", not an "el")
for INFILE in $(ls -1 *.caf)

  # get the base filename by stripping off the ".caf" part
  baseFilename=`basename "${INFILE}" .caf`

  # determine the preliminary output filename

  # convert all spaces to hyphens
  outfile=`echo $outfile | tr -s " " "-"`
  echo "Converting \"$INFILE\" to \"$outfile\" ..."

  # now convert the CAF file to an AIF file
  afconvert -f AIFF -d I8 "$INFILE" "$outfile"


This script doesn’t do anything to your input files. If there are no bugs in the script, they stay just the way they were. (Though of course you should back them up just to be safe.) It just creates an AIF file for each CAF file it sees.

This script seems to properly handles filenames that have blank spaces in them. I just used it to convert a number of Apple’s iLife sound effects files, and almost all of those have spaces in the filenames, so again, this script deals with that as well.

An afconvert command to convert a CAF file to an AIF, MP3, or WAV file

If you don’t need all that horsepower, and just need to convert one CAF file to an AIF file, just use a command like this:

afconvert -f AIFF -d I8 MyInputFile.caf MyOutputFile.aif

CAF, WAV, MP3, AIFF, AIFC, AU file formats, etc.

If you need to convert other sound file formats, it appears that the afconvert utility can deal with many of those formats. Type this command on your Mac OS X system for basic help on the afconvert utility:

afconvert -h

But if you want to see all the formats the afconvert utility can deal with, type this command instead:

afconvert -hf

This gives you the following output, at least on a Mac OS X 10.6 system:

$ afconvert -hf

Audio file and data formats:

'3gpp' = 3GP Audio (.3gp)
           data_formats: 'aac ' 'samr' 
'3gp2' = 3GPP-2 Audio (.3g2)
           data_formats: 'aac ' 'samr' 
'adts' = AAC ADTS (.aac, .adts)
           data_formats: 'aac ' 'aach' 
'ac-3' = AC3 (.ac3)
           data_formats: 'ac-3' 
'AIFC' = AIFC (.aifc, .aiff, .aif)
           data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 'ulaw' 
                         'alaw' 'MAC3' 'MAC6' 'ima4' 'QDMC' 'QDM2' 
                         'Qclp' 'agsm' 
'AIFF' = AIFF (.aiff, .aif)
           data_formats: I8 BEI16 BEI24 BEI32 
'amrf' = AMR (.amr)
           data_formats: 'samr' 
'caff' = Apple CAF (.caf)
           data_formats: '.mp1' '.mp2' '.mp3' 'QDM2' 'QDMC' 'Qclp' 
                         'Qclq' 'aac ' 'aach' 'aacl' 'alac' 'alaw' 
                         'dvi8' 'ilbc' 'ima4' I8 BEI16 BEI24 BEI32 
                         BEF32 BEF64 LEI16 LEI24 LEI32 LEF32 LEF64 
                         'ms\x00\x02' 'ms\x00\x11' 'ms\x001' 'samr' 
'm4af' = Apple MPEG-4 Audio (.m4a)
           data_formats: 'aac ' 'aach' 'aacl' 'alac' 
'MPG1' = MPEG Layer 1 (.mp1, .mpeg, .mpa)
           data_formats: '.mp1' 
'MPG2' = MPEG Layer 2 (.mp2, .mpeg, .mpa)
           data_formats: '.mp2' 
'MPG3' = MPEG Layer 3 (.mp3, .mpeg, .mpa)
           data_formats: '.mp3' 
'mp4f' = MPEG-4 Audio (.mp4)
           data_formats: 'aac ' 'aach' 'aacl' 
'NeXT' = NeXT/Sun (.snd, .au)
           data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 'ulaw' 
'Sd2f' = Sound Designer II (.sd2)
           data_formats: I8 BEI16 BEI24 BEI32 
'WAVE' = WAVE (.wav)
           data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw' 

In summary, I hope this article on converting sound files (CAF, AIF, MP3, WAV, AU) on Mac OS X has been helpful. As usual, any comments, suggestions, etc., just use the form below.


Thanks, I'm gonna try this


This info about 'afconvert' is great help to me.
Thank you!

I'm just learning how to do basic scripting, and this helped me a lot. I especially appreciated your detailed commenting explaining what each line does, since it makes a lot of sense but I'm not used to the syntax.

I couldn't use ls -l, though. This script tried to convert everything on the line when I did it that way. I took out the -l and it worked.


This solves how to convert all my Logic Pro loops so I can use them in other DAWs (because you can't slave Logic). I thank you thank you thank you for this script!

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.