[KLUG Members] case

Bruce Smith members@kalamazoolinux.org
05 Apr 2002 15:25:41 -0500


> What is the most efficient way to take everything in a folder and change the 
> entire contents to lowercase?  I just copied over a backup from CDR of a 
> website that has over 600 files and don't want to do this on a file by file 
> basis.

I created a shell script that converts all files specified to lower case
(or upper case).

Name the script "lowerfile", move it to your path, cd to the directory
where the files are and run:

  lowerfile *

You can also name it (or link it) to the name "upperfile" and it does
the opposite.

The script:

====================================================================
#!/bin/sh
if [ `basename $0` = upperfile ]; then
        infile=lower
        outfile=upper
else
        infile=upper
        outfile=lower
fi
for f
do
	if [ -f "$f" ]; then
		l=`echo "$f" | tr "[:${infile}:]" "[:${outfile}:]"`
		if [ "$f" != "$l" ]; then
			set -x
			mv "$f" "$l"
			set +x
		fi
        fi
done
====================================================================


--------------------------------------------
Bruce Smith                bruce@armintl.com
System Administrator / Network Administrator
Armstrong International, Inc.
Three Rivers, Michigan  49093  USA
http://www.armstrong-intl.com/
--------------------------------------------