#!/bin/ksh
# @(#) lowercase.ksh 1.0 92/10/08
# 92/10/08 john h. dubois iii (john@armory.com)

if [ $# -eq 0 -o "$1" = -h ]; then
    echo \
"$0: change filenames to lower case.
Usage: $0 file ...
Each file is moved to a name with the same directory component, if any,
and with a filename component that is the same as the original but with
any upper case letters changed to lower case."
    exit
fi

typeset -l filename

for file; do
    filename=${file##*/}
    newname="${file%%*([!/])}$filename"
    if [ "$newname" != "$file" ]; then
	mv "$file" "$newname"
	echo "$file -> $newname"
    else
	echo "$file not changed."
    fi
done
