The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: Re: [OT] Outlook 2003 help please


[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

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.