Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.wizards Subject: Re: HELP converting filenames! Message-ID: <6121@jpl-devvax.JPL.NASA.GOV> Date: 29 Sep 89 07:07:41 GMT References: <9234@pyr.gatech.EDU> <15058@nuchat.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 44 In article <15058@nuchat.UUCP> steve@nuchat.UUCP (Steve Nuchia) writes: : In article <9234@pyr.gatech.EDU> david@pyr.gatech.edu (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 : : With friends like these, who needs VM/CMS? : : : for x in * : do mv $x `echo $x | tr A-Z a-z` : done : : or in csh : : foreach x (*) : mv $x `echo $x | tr A-Z a-z` : end Or, more efficiently, if you have the rename perl script handy: rename y/A-Z/a-z/ * For those who missed it, here's a simple version of the script: #!/usr/bin/perl $op = shift; for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; } The first argument is any old perl expression that modifies $_. So you can do commands like: rename 's/\.orig$//' *.orig rename 'y/A-Z/a-z/ unless /^Make/' * rename '$_ .= ".bad"' *.f rename 'print "$_: "; s/foo/bar/ if=~ /^y/i' * Larry Wall lwall@jpl-devvax.jpl.nasa.gov