#!/bin/tcsh ########################################################### # audmunge - shell script to convert a directory of compressed audio # v1.1 plutek 2008-02-25 ########################################################### # N.B. needs tcsh for "foreach" command # set destination directory root set dest_dir = /mnt/usb/plutek/lau-cb-work/temp/munged # check that we really want to operate from pwd echo "####################################################" echo "destination root for processed files is: $dest_dir" echo "" echo "here is what will be operated on:" echo "" pwd echo "" ls echo "" echo -n "is it ok to operate from that directory? (only y continues) " set ans = $< if ( $ans == "y" ) then # copy everything to the working directory, so we don't mess up the mirror echo "####################################################" echo "copying from" pwd echo "to $dest_dir" echo "####################################################" cp * $dest_dir cd $dest_dir echo "contents of $dest_dir :" ls # change any ":" to "_" echo "####################################################" echo "changing all ':' to '_'" echo "####################################################" rename : _ * echo "contents of $dest_dir :" ls # de-compress it all echo "####################################################" echo "decompressing" echo "####################################################" # de-ogg foreach file ( * ) if ( $file =~ *ogg ) then oggdec $file # de-wv (over-writes oggs which are also wvs, if filenames were consistent) # -y parameter means say "yes" to all over-write prompts else if ( $file =~ *wv ) then wvunpack -y $file endif end # make a mono version of all wav files echo "#######################################################" echo "sorting files by mono/stereo/other and processing..." echo "#######################################################" foreach file ( *wav ) set audiotype = "`file $file`" echo "$audiotype" if ( "$audiotype" =~ *mono* ) then mv $file $dest_dir/mono/$file.mono.wav else if ( "$audiotype" =~ *stereo* ) then sox -c 2 $file -c 1 $dest_dir/stereo/$file.mono.wav && mv $file $dest_dir/stereo/ else mv $file $dest_dir/unknown/ endif end echo "####################################################" echo "cleaning up" # remove all unused files rm $dest_dir/* # print a help message echo "" echo "################################################################################" echo "# please check $dest_dir/stereo" echo "# and $dest_dir/unknown ----" echo "#" echo "# which stereo ones need the mono version?" echo "# what do we do with the unknown ones?" echo "################################################################################" echo "" ls -Rl && ls -Rl > $dest_dir/filelist.txt exit 0 else echo "#####################################################################" echo "please cd to the proper directory of source files, and restart..." echo "#####################################################################" endif exit 127 fi