HELP converting filenames!
Larry Wall
lwall at jpl-devvax.JPL.NASA.GOV
Fri Sep 29 17:07:41 AEST 1989
In article <15058 at nuchat.UUCP> steve at nuchat.UUCP (Steve Nuchia) writes:
: In article <9234 at pyr.gatech.EDU> david at 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 <stdin> =~ /^y/i' *
Larry Wall
lwall at jpl-devvax.jpl.nasa.gov
More information about the Comp.unix.wizards
mailing list