#!/bin/ksh
# renameL2 - Korn shell script from UVSI stored in: /home/uvadm/sf/util/
# renameL2 - rename an entire directory of filenames to lower case
#          - ## DISABLE prompt to continue & list renamed files
# renameL  - original version that does prompt continue & lists renamed files
#
echo "rename all filenames in subdir to lower case"
if [ -d "$1" ]; then :
   else echo "usage: renameL2 directory"
        echo "       =================="
        echo " - arg1 must be a directory"
        exit 1; fi
#
## echo -n "Rename all files in $1 to lower case OK? (or cancel)"; read reply
x=0; y=0
for i in $1/*
do let x=x+1
   f=${i##*/}
   typeset -l g=$f
   if [[ $g != $f ]]; then
      mv -i $1/$f $1/$g
      #================
      let y=y+1
      ## echo "file# $y (of $x) $1/$f - renamed to: $1/$g"
   fi
done
echo "total $y files in ${1}, $x renamed to lower case"
exit 0
