sub SelectFiles($$$$;$$){
my ($srcPathPattern, $srcFile, $desPath, $desFile) = @_;
my $srcPath = dirname($srcPathPattern);
my $folderPattern = basename($srcPathPattern);
#print "$srcPathPattern, $srcPath, $folderPattern\n";
my @folders;
opendir DH, $srcPath or die("Can't open dir: $srcPath\n");
foreach my $folder(readdir DH) {
#print "\none file in $srcPath is $folder\n";
if($folder =~ /$folderPattern/){
push(@folders, $folder);
}
}
@folders = sort @folders;
#print "@folders\n";
closedir(DH);
my @files;
foreach(@folders){
my $dirTmp = PathConnection($srcPath, $_);
#print "$dirTmp\n";
opendir DH_Tmp, $dirTmp or die("Can't open dir: $dirTmp\n");
foreach my $file(readdir DH_Tmp) {
#print "one file in $dirTmp is $file\n";
if($file =~ /$srcFile/){
my $fullpathfile = PathConnection($dirTmp, $file);
push(@files, $fullpathfile);
}
}
closedir(DH_Tmp);
}
@files = sort @files;
#print "@files\n";
return $TRUE;
}
my ($srcPathPattern, $srcFile, $desPath, $desFile) = @_;
my $srcPath = dirname($srcPathPattern);
my $folderPattern = basename($srcPathPattern);
#print "$srcPathPattern, $srcPath, $folderPattern\n";
my @folders;
opendir DH, $srcPath or die("Can't open dir: $srcPath\n");
foreach my $folder(readdir DH) {
#print "\none file in $srcPath is $folder\n";
if($folder =~ /$folderPattern/){
push(@folders, $folder);
}
}
@folders = sort @folders;
#print "@folders\n";
closedir(DH);
my @files;
foreach(@folders){
my $dirTmp = PathConnection($srcPath, $_);
#print "$dirTmp\n";
opendir DH_Tmp, $dirTmp or die("Can't open dir: $dirTmp\n");
foreach my $file(readdir DH_Tmp) {
#print "one file in $dirTmp is $file\n";
if($file =~ /$srcFile/){
my $fullpathfile = PathConnection($dirTmp, $file);
push(@files, $fullpathfile);
}
}
closedir(DH_Tmp);
}
@files = sort @files;
#print "@files\n";
return $TRUE;
}