#!/bin/bash
#20080624 - Author: Gregg Hansen 
#http://www.thiscoolsite.com
#Make sure to install Lame and copy mlame to your .wav dir
#If you specify your own filenames, use NO spaces.

recorddir="/var/spool/asterisk/monitor"
for i in `ls $recorddir/*.wav`; do
cd $recorddir    
$recorddir/mlame -f -o "-b 16 -m m -q 9 --resample 8" $i
date=`ls -l $i | awk '{print $7,$6,2008,$8}'`
mp3=`echo $i | sed 's/.wav/.mp3/g'`
touch -d "$date" $mp3

#Uncomment the below line if you want your .wavs moved to a different directory.
#This way you can review the timestamps and mp3 files before deleting the .wav
#mv $i /wav_recordings
done

