if test $# -eq 0
then
        echo "\n   aiffd converts NEXT sound files into AIFF sound files"\
                "\n   using sfconvert. The source is deleted.\n\n\
        \nUsage: \n\n\taiffd [.snd sound file(s)]\n\n"
else
   while test $# -gt 0
   do
	nexttest=`sfinfo $1 | grep "File Format" | awk '{print $7}'`

        if test $nexttest != "(next)"
        then
		if test ! -s $1
		then
			notfound="$notfound $1"
			echo $1 is not a file!
		else
			echo $1 is not an .snd file!
		fi
		noconvert="$noconvert $1"

        elif test -s $1
	then
		newname=`echo $1 | sed s/.snd//g`
		newname="$newname".aiff
		echo CONVERTING...............................................
                sfconvert $1 $newname format aiff integer 16 2
		
		if test -r $newname
		then
   		    echo ................SUCCESS!
		    convert="$convert $newname"
		    rm $1
		    deleted="$deleted $1"
		    echo $1 has been DELETED.

		else
		    echo .............FIXING FILE...................
		    fixnext $1
		    echo ............TRY AGAIN ...................
		    sfconvert $1 $newname format aiff integer 16 2
		    if test -r $newname
		    then
			echo ................SUCCESS!
			convert="$convert $newname"
			rm $1
			deleted="$deleted $1"
			echo $1 has been DELETED.

		    else
			echo "I'M HAVING REAL PROBLEMS CONVERTING $1. BYE."
			problemconvert="$problemconvert $1"
		    fi
		fi
   		echo ......................................................DONE!




############################


############################


	else
		notfound="$notfound $1"
        fi
        shift
   done

   if test -n "$deleted"
   then echo "\n--------DELETED FILES----------:\n\t $deleted"
   fi
   if test -n "$convert"
   then echo "\n*******NEW CONVERTED FILES*******:\n\t $convert"
   fi
   if test -n "$noconvert"
   then echo "\n(((((((NON NEXT FILES))))))))) (No action taken):\n\t $noconvert"
   fi
   if test -n "$notfound"
   then echo "\n?????????FILES NOT FOUND????????:\n\t $notfound"
   fi
   if test -n "$problemconvert"
   then echo "\n!!!!!!!!! PROBLEM FILES !!!!!!!!!(No action taken):\n\t $problemconvert"
   fi
echo ""
fi




