home *** CD-ROM | disk | FTP | other *** search
Korn shell script | 1997-08-26 | 635 b | 27 lines |
- #!/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
-