#!/bin/csh ############################################################### # This program will encode all of the WAV files it finds in # the named directory into MP3 files. It deletes each WAV # file once it has been converted. # # It returns 0 on success, nonzero on failure. ############################################################## ############################################################## # Argument checking # Make sure they passed in the name of a directory set directory = $1 if (0 == `echo -n "$directory" | wc -c`) then echo "Usage: $0 directory_to_convert" exit 1 endif # Make sure that the directory exists if (-e "$directory") then else echo "Error: directory $directory does not exist" exit 1 endif ############################################################## # Find all of the WAV files under the directory and convert # them one at a time, deleting the WAV file for each after # it has been converted. Do this at reduced priority so # we don't interfere with other things going on too much. foreach nextfile ( `find "$directory" -name \*.wav` ) echo Converting $nextfile nice +10 lame --preset standard --quiet "$nextfile" if ( 0 == $status ) then rm $nextfile endif end ############################################################## # Done exit 0