HELP converting filenames!

Randal Schwartz merlyn at iwarp.intel.com
Wed Oct 4 00:48:26 AEST 1989


In article <9234 at pyr.gatech.EDU>, david at 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 at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/



More information about the Comp.unix.wizards mailing list