Changing upper-case filenames to lower-case

Jim Rogers jimr at hp-lsd.COS.HP.COM
Fri Jan 5 08:43:23 AEST 1990


I was surprised that no one came up with the simple and efficient ksh
answer to this:


#!/bin/ksh
typeset -i flag
(( flag = 0 ))
set -- `getopt du $*`
for i in $*
do
	case $i in
	-d)	typeset -l nf; (( flag = 1 )); shift;;
	-u)	typeset -u nf; (( flag = 1 )); shift;;
	--)	shift; break;
	esac
done
if (( flag == 0 ))
then
	typeset -l nf
fi
while [ $# -gt 0 ]
do
	nf=${1}
	if [ "$nf" != "$1" ]
	then
		print "Do you want to convert ${1} to ${nf} (Y/N)?"
		read
		if [ "$REPLY" = "Y" -o "$REPLY" = "y" ]
		then
			print "Moving ${1} to ${nf}"
			mv ${1} ${nf}
		fi
	fi
	shift
done


This version will shift up or down as you please.
To shift up use the "-u" option.
To shift down either use the "-d" option or no option.


Jim Rogers



More information about the Comp.unix.questions mailing list