I want to convert a couple of hundred file names in a folder from upper case to lower case.
e.g. /tmp/UPPERCASE1.DATA to /tmp/uppercase2.data
I'm using a Solaris 2.8 platform. Is there a neat awk script that can do this?
Doesn't handle characters with "funny" filenames and probably doesn't handle spaces in the filename:
# tolower.sh: convert file names to lower case
# in the current working directory
# Choose either all the files in a directory or
# a command-line list
if [ "$#" -gt 0 ]; then
filelist="$@" # just the files on command line
else
filelist=`ls` # all files
fi
for file in $filelist; do
# Use the grep command to determine if the file
# has an upper case letter
# Determine the destination of the mv command by
# down shifting all the
# letters in the file name. Command substituting an
# echo of the file name to the translate filter, tr,
# performs the downshift
if echo "$file"|grep [A-Z] > /dev/null; then
mv "$file" `echo "$file"|tr "[A-Z]" "[a-z]"`
fi
done
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.