use File::Find;
# Recurse down the directory tree, calling the 'wanted'
# function whenever something is found.
find(\&wanted, 'c:\ord\ixx\data\log');
sub wanted {
# Select the files required
if (/^[a-z]{4,}/i) {
# (xcopy used because it automatically creates all the necessary directories)
system "xcopy \"$File::Find::name\" c:\\data\\ /i/f/y";
}
else {print "Rejecting $File::Find::name\n";}
}
Main Topics
Browse All Topics





by: J1mboPosted on 2002-12-05 at 04:20:15ID: 7536310
#! /bin/perl
$source_dir = "C:\ORD\IXX\DATA\LOG";
$dest_dir = "C:\DATA\";
opendir(DIR, "$source_dir ") || die can't open: $!\n;
@files = readdir(DIR);
closedir(DIR);
foreach $file (@files) {
system("copy ${source_dir}$file $dest_dir") if $file =~ m(^ABCD);
}
- I don't have perl on windows to test this, but it should be ok.
-jim