This is untested, but Try this: #!/bin/sh if [ -z $1 ]; then echo "You didn't specify a directory!"; exit 1; elif [ -d $1 ]; then tf=/tmp/renamer.$$; rm -f $tf; ls *[A-Z]* | awk '{print "mv", $1, tolower($1)}' > $tf; source $tf; exit 0; else echo "$1 is not a directory!"; exit 2; fi