use strict;
use warnings;
use FileHandle;
use File::Basename;
use File::Copy;
use File::Find;
my @dirs;
find({
no_chdir => 1,
wanted => sub {
return unless -d;
my $base = basename($_);
return unless $base =~ /MPBHSM_PU(\d+)/io;
push(@dirs,$_);
return;
}
},'E:/Geomodeler');
opendir(GIS,'\\\\Storage1\\PUBLIC\\GIS\\xBatchModelRunDirectory') or die;
my @spc = splice(@{[ readdir(GIS) ]},2);
print "$_\n" foreach @spc;
closedir(GIS);
foreach my $spc (@spc) {
opendir(SPC,"\\\\Storage1\\PUBLIC\\GIS\\xBatchModelRunDirectory\\$spc") or die;
my ($mdl,$ctrl) = splice(@{[ readdir(SPC) ]},2);
my @fh = (new FileHandle,new FileHandle);
$fh[0]->open("\\\\Storage1\\PUBLIC\\GIS\\xBatchModelRunDirectory\\$spc\\$mdl",'<');
$fh[1]->open("\\\\Storage1\\PUBLIC\\GIS\\xBatchModelRunDirectory\\$spc\\$ctrl",'<');
map { defined $_ or die } @fh;
foreach my $dir (@dirs) {
chdir(join('/',$dir,'Models/In/Run1')) or die;
print $dir, "\n";
mkdir($spc,0777) or die unless -d $spc;
chdir($spc) or die;
copy($fh[0],$mdl) or die;
copy($fh[1],$ctrl) or die;
my $fh = new FileHandle;
$fh->open(join('/',$dir,'Models/Out/Run1/res1_out.cas'),'<');
die unless defined $fh;
print "copying cas\n";
copy($fh,'res1_out.cas') or die;
chdir('..');
}
chdir('..');
}
print 1;