I was looking for a simple and elegant way to convert a high amount of audio files from one format (.caf) to another (.aif). The solution i found is a very elegant one and also comes included with your operating system – if using a MAC.
1 |
afconvert -f AIFF -d BEI24@48000 "Wow Bass 03.caf" "Wow Bass 03.aif" |
And now here is the most amazing part. It is super easy to execute the conversion of multiple files by just one command line.
1 |
for i in *.caf; do afconvert -f AIFF -d BEI24@48000 "$i" "${i%.caf}.aif"; done |
or to run through subdirectories:
1 2 3 |
for d in */ ; do cd $d; pwd; cd ..; done for d in */ ; do cd $d; for i in *.caf; do echo *caf; pwd; done; cd ..; done; for d in */ ; do cd $d; for i in *.caf; do afconvert -f AIFF -d BEI24@48000 "$i" "${i%.caf}.aif"; done; cd ..; done |
or with recursion by using find:
1 2 3 |
find -name "*.caf" find . -type f -iname '*.caf' -print | while read -r name; do cp "$name" "/.../..."; done find . -type f -iname '*.caf' -print | while read -r name; do afconvert -f AIFF -d BEI24@48000 "$name" "/Volumes/Daten/Logic/test/${name%.*}.aif"; done |
Key | linear PCM format |
LE | Little Endian |
BE | Big Endian |
F | Floating point |
I | Integer |
UI | Unsigned integer |
8/16/24/32/64 | Number of bits |
Number of bits | Information Size |
8 | 256 |
16 | 65536 |
24 | 16777216 |
32 | 4294967296 |
64 | 18446744073709551616 |
1 |
afconvert -hf |
Audio file and data formats: | data_formats: |
‘3gpp’ = 3GP Audio (.3gp) | ‘Qclp’ ‘aac ‘ ‘aace’ ‘aach’ ‘aacl’ ‘aacp’ ‘samr’ |
‘3gp2’ = 3GPP-2 Audio (.3g2) | Qclp’ ‘aac ‘ ‘aace’ ‘aach’ ‘aacl’ ‘aacp’ ‘samr’ |
‘adts’ = AAC ADTS (.aac, .adts) | ‘aac ‘ ‘aach’ ‘aacp’ |
‘ac-3’ = AC3 (.ac3) | ‘ac-3’ |
‘AIFC’ = AIFC (.aifc, .aiff, .aif) | I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 ‘ulaw’ ‘alaw’ ‘MAC3’ ‘MAC6’ ‘ima4’ ‘QDMC’ ‘QDM2’ ‘Qclp’ ‘agsm’ |
‘AIFF’ = AIFF (.aiff, .aif) | I8 BEI16 BEI24 BEI32 |
‘amrf’ = AMR (.amr) | ‘samr’ |
‘m4af’ = Apple MPEG-4 Audio (.m4a, .m4r) | ‘aac ‘ ‘aace’ ‘aach’ ‘aacl’ ‘aacp’ ‘alac’ |
‘caff’ = CAF (.caf) | ‘.mp1’ ‘.mp2’ ‘.mp3’ ‘QDM2’ ‘QDMC’ ‘Qclp’ ‘Qclq’ ‘aac ‘ ‘aace’ ‘aach’ ‘aacl’ ‘aacp’ ‘alac’ ‘alaw’ ‘dvi8’ ‘ilbc’ ‘ima4’ I8 BEI16 BEI24 BEI32 BEF32 BEF64 LEI16 LEI24 LEI32 LEF32 LEF64 ‘ms\x00\x02’ ‘ms\x00\x11’ ‘ms\x001’ ‘paac’ ‘samr’ ‘ulaw’ |
‘MPG1’ = MPEG Layer 1 (.mp1, .mpeg, .mpa) | ‘.mp1’ |
‘MPG2’ = MPEG Layer 2 (.mp2, .mpeg, .mpa) | ‘.mp2’ |
‘MPG3’ = MPEG Layer 3 (.mp3, .mpeg, .mpa) | ‘.mp3’ |
‘mp4f’ = MPEG-4 Audio (.mp4) | data_formats: ‘aac ‘ ‘aace’ ‘aach’ ‘aacl’ ‘aacp’ |
‘NeXT’ = NeXT/Sun (.snd, .au) | I8 BEI16 BEI24 BEI32 BEF32 BEF64 ‘ulaw’ |
‘Sd2f’ = Sound Designer II (.sd2) | I8 BEI16 BEI24 BEI32 |
‘WAVE’ = WAVE (.wav) | UI8 LEI16 LEI24 LEI32 LEF32 LEF64 ‘ulaw’ ‘alaw’ |
for i in *.caf; do afconvert -f AIFF -d BEI24@48000 “$i” “${i%.caf}.aif”;echo $i; done
for return of the single files converted