Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!oliveb!mipos3!omepd!merlyn
From: merlyn@iwarp.intel.com (Randal Schwartz)
Newsgroups: comp.unix.wizards
Subject: Re: HELP converting filenames!
Summary: (warning: plug for Perl again...)
Message-ID: <5003@omepd.UUCP>
Date: 3 Oct 89 14:48:26 GMT
References: <9234@pyr.gatech.EDU>
Sender: news@omepd.UUCP
Reply-To: merlyn@iwarp.intel.com (Randal Schwartz)
Organization: Stonehenge; netaccess via Intel, Hillsboro, Oregon, USA
Lines: 34
In-reply-to: david@pyr.gatech.EDU (David Brown)

In article <9234@pyr.gatech.EDU>, david@pyr (David Brown) writes:
| 
| Hiya.  I have a friend who has about 200 files in a directory that are all
| upper case.  They are data files that need to be in lower case, because
| his brain-dead program won't recognize upper case letters.  It's a i386
| box, running some form of Xenix, but he doesn't have the development system.
| Can any of you Bourne shell or C-shell wizards out there tell me how to
| write a script that will convert them?  He's VERY anxious to get them
| converted (he's almost dead in the water until he does).

Yeah, in Perl, it'd be:

for $old (<*>) {
	($new = $old) =~ y/A-Z/a-z/;
	rename($old,$new) || warn "Cannot rename $old to $new ($!)";
}

But, if you don't have Perl (shame on you!), here's the /bin/sh (et. al.)
solution:

for old in *
do
	mv $old `echo $old | tr A-Z a-z`
done

Of course, with this solution, you are firing off four processes for
each file, but it still works.  Might take a while for 200 names.

Just another Perl hacker,
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III  |
| merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/