#!/bin/sh
#
# shn - compress wav files using shorten.  Pass it a directory name,
# file name, or list of both, and it will shorten up all the files in
# that set.  The shn files replace the wav files.
#
# Author: Caleb Epstein <cae at bklyn dot org>
#
# $Id: shn,v 2.1 2002/09/25 02:14:22 cepstein Exp $

# shnify - simple wrapper function for extracting a SHN file.  Does
# *very* rudimentary error checking.
shnify()
{
   file=$1
   shorten $file `basename $file .wav`.shn \
      && echo "$file: OK" || echo "$file: ERROR"
}

# Work on the current directory if no arguments were passed
if [ $# -lt 1 ]; then
   set .
fi

for file
do
   if [ -f $file ]; then
      shnify $file
   elif [ -d $file ]; then
      dir=$file
      for file in `find $dir -type f -iname "*.wav" -print`
      do
         shnify $file
      done
   fi
done
