change file names
Steven W. Orr
steveo at syslang.net
Tue Feb 21 13:39:01 EST 2006
On Tuesday, Feb 21st 2006 at 10:39 -0500, quoth Tom Buskey:
=>I've been using this perl script for a few years. I got it from UGU's daily
=>scripts.
=>
=>ren 's/exp1/exp2/' *txt
=>
=>It has some error checking so it won't overwrite existing files. Most
=>scripts I've seen for renaming don't do that because they're quick hacks for
=>a special case.
=>
This script is a slightly shameless ripoff of the rename script in the
camel book:
#!/usr/bin/perl
$op = shift;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
To elaborate further, both of these are cool because you get access to all
of perl's regexp capabilities. e.g., (besides the one above)
rename 'tr/A-Z/a-z/' $filelist
to take a bunch of DOS filenames and flip them all to lowercase.
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
More information about the gnhlug-discuss
mailing list