Neat utility to convert uppercase filenames

Flint Pellett flint at gistdev.gist.com
Tue Dec 11 06:44:11 AEST 1990


jay at gdx.UUCP (Jay A. Snyder) writes:


>Did you ever do mget from simtel20 or ymodem batch downloads from an MSDOS
>BBS, and get a lot of uppercase files in your directory?

>Well this is a utility that will take all specified files and convert
>them to lower case.

>One exception is that trailing .Z's will be left uppercase

Rather a bit of overkill to write a C program for it isn't it?
The script below, hacked out in about 30 seconds, does most of what
want-- adding an -if- to check for the trailing .Z files is left
as an exercise for the reader :-).  You can also add a check for
a $1 that was already all lower case if you want.

#!/bin/ksh
while [ -n "$1" ]
do
    typeset -l LC="$1"
    mv "$1" "${LC}"
    shift
done

I suppose I should offer a (slower) Bourne shell version for
anyone unlucky enough to still be limited to that:  I'm 
sure someone can probably improve on this and make it even
shorter. (You can probably write it in perl in 1 line.)

#!/bin/sh
while [ "$1" != "" ]
do
    mv $1 `echo $1 | tr "[A-Z]" "[a-z]"`
    shift
done
-- 
Flint Pellett, Global Information Systems Technology, Inc.
1800 Woodfield Drive, Savoy, IL  61874     (217) 352-1165
uunet!gistdev!flint or flint at gistdev.gist.com



More information about the Alt.sources mailing list