Helpful: audio files batch conversion

Here's what I do when I have a bunch of aif files that need to become wav files. You will need SoX to do this.

AIF2WAV

#! /bin/sh cd $1
for file in *.aif
do
#echo $file name=
basename ${file} .aif #echo $name #echo "---" wave=${name}.wav #echo $wave sox $file $wave mv $file aif done

First argument to the script is the directory to use. The echo statements are not necessary, but you might want to try uncommenting them to see the values of the variables. Assuming there is an "aif" folder in your sound file folder, the aifs will be moved there after conversion.

TO16BITS

And here's what I do for 32- or 24-bit files that need to become 16-bits. You could add in the copying trick as above if you wanted to copy the files with the wrong bit-rate to a directory just in case you needed the higher bit-rate versions in the future.

#! /bin/sh cd $1
for file in *.aif
do
name=[bt]basename ${file} .aif[bt] sox $file ${name}_16.wav done

You can easily be copying in place if you change the arguments slightly, so be careful. ([bt] is a backtick, since markdown will not allow that character.)

TOMP3

SoX is also great for converting sound files to Layer 2 MP3 files. This is required for MP3s to be loaded by certain programming libraries. It's quite easy.

sox foo.aif foo.mp3

This all depends on SoX, a great little command-line program for miscellaneous audio tasks. Check it out if you don't already know it. In theory you could produce music using just this tool, if you absolutely had to...