TheLinuxDuck
10-14-2000, 10:12 PM
Ok, here's a perl snippet that will scan for all files in a given dir and recurse through all subdir's. It works great. Except for when you give a wildcard and a partial filename.
If that is the case, and it doesn't find any files in the current dir matching that filename, the search function chokes.
I guess I need to just offer the ability to list what file extensions to rename...
#!/usr/bin/perl -w
use strict;
use File::Find;
my (@newfiles)=();
if($#ARGV>0) {
my ($frontend,@files)=@ARGV;
find (\&search, @files);
rename ($newfiles[$_],$frontend . $newfiles[$_]) for 0..$#newfiles;
print "@newfiles\n";
}
else {
die "Usage: $0 pre-extension filename [filename] [..]\n";
}
sub search
{
push (@newfiles,$File::Find::name) if(!-d);
}
------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq
[This message has been edited by TheLinuxDuck (edited 16 October 2000).]
If that is the case, and it doesn't find any files in the current dir matching that filename, the search function chokes.
I guess I need to just offer the ability to list what file extensions to rename...
#!/usr/bin/perl -w
use strict;
use File::Find;
my (@newfiles)=();
if($#ARGV>0) {
my ($frontend,@files)=@ARGV;
find (\&search, @files);
rename ($newfiles[$_],$frontend . $newfiles[$_]) for 0..$#newfiles;
print "@newfiles\n";
}
else {
die "Usage: $0 pre-extension filename [filename] [..]\n";
}
sub search
{
push (@newfiles,$File::Find::name) if(!-d);
}
------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq
[This message has been edited by TheLinuxDuck (edited 16 October 2000).]