Tag Archives: commandline

Converting Game Sound Assets via OS X to Save Space and Memory

Another audio-related mini-post!

I had mentioned on Twitter earlier how I had written a script to convert all the WAV assets in Red Nova from unnecessarily large 32-bit floating point 44 kHz format to a space and memory saving 16-bit integer 22 kHz format. This basically cut the size of the files to less than half, which is pretty fantastic when you’re dealing with a hand-held device with memory constraints like the iPhone. Hell, it will also improve loading times!

Anyway someone asked me to share the script I made, which is a fairly simple Bash script. Just create a file somewhere, call it something like convertwavs.sh, and paste the following into it:

mkdir oldwavs
for f in *.wav
   cp $f oldwavs/$f
   afconvert -f WAVE -d LEI16@22050 $f $f

Run chmod +x convertwavs.sh from the terminal to make it executable, then change to the folder containing the WAV files you want to convert and run the script like so:


It will make a sub-folder called oldwavs and copy the originals there in case anything goes wrong and then convert the files in place. That’s it!