home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
2
/
2245
< prev
next >
Wrap
Internet Message Format
|
1990-12-28
|
949b
From: tchrist@convex.COM (Tom Christiansen)
Newsgroups: alt.sources
Subject: Re: Neat utility to convert uppercase filenames
Message-ID: <110060@convex.convex.com>
Date: 8 Dec 90 03:40:18 GMT
Here's one version of rename, a generic utility to
perform infinite contortions on your filenames. It's
surely more powerful than anything of its ilk I've
ever seen before.
--tom
#!/usr/bin/perl
#
# rename script examples from lwall:
# rename 's/\.orig$//' *.orig
# rename 'y/A-Z/a-z/ unless /^Make/' *
# rename '$_ .= ".bad"' *.f
# rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' *
#
# shows good use of eval operator
$op = shift;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
--
Tom Christiansen tchrist@convex.com convex!tchrist
"With a kernel dive, all things are possible, but it sure makes it hard
to look at yourself in the mirror the next morning." -me