[Date Prev][Date
Next][Thread Prev][Thread Next][Date
Index][Thread Index]
Re: Tag & Rename question....
On Wednesday 21 May 2003 14:26, Doogie Brodie wrote:
> Ant wrote:
> > Try the attached script instead. It doesn't recurse, and has a
test-only
> > option.
>
> Ant - the list is set to eat attachments to prevent a lot of the
viruses
> that abuse attachments... :
Shite! I mailed it to PaulG direct, but here it is again anyway:
#!/usr/bin/perl
#
# dirrename.pl [-t] [dir] - default is current dir
#
# rename all dirs in [dir] that match "foo - bar" to
"bar"
# use -t for test only (no renaming)
use Getopt::Std;
getopts('t');
$test = 0;
if($opt_t) {
$test = 1;
}
$root = shift @ARGV ".";
opendir DH, $root or die "arse!";
@dirs = grep { -d "$root/$_" } readdir(DH);
closedir DH;
for (@dirs) {
$old = $_;
if(s/.*-\s*//) {
print "$root/$old -> $root/$_ :";
if(-e "$root/$_") {
print "can't rename, $_ already exists\n";
} else {
rename "$root/$old", "$root/$_" unless $test;
print "OK\n";
}
}
}
cheers
ant
--
/\/\
www.ant.org ('') www.ant.org
()
Megawatt Winged Avenger
Home |
Main Index |
Thread Index
|