# !perl use strict; # because we should use warnings; # because we should my $base = 'D:\Some\Specific\Folder\Archive\\'; # This might hurt your eyes, but for some obscure reason, DateTime is not installed and I can seriously not be bothered to install it myself my @years = ('2011','2012','2013','2014','2015','2016','2017'); my @months = ('01','02','03','04','05','06','07','08','09','10','11','12'); my @days = ('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'); my $archive = glob qq($base.Gridfee0?.7z\\); #Tried glob qq($base.Gridfee0?.7z\\Gridfee*\\) and glob qq($base.Gridfee0?.7z) too, same result foreach my $year (@years) { foreach my $month (@months) { foreach my $day (@days) { my @files = glob qq($base\\Gridfee0?.7z\\Gridfee?\\invoic_b2c_$year$month$day*.txt); # The zipfiles are zipped folders, so there is 1 extra layer to traverse, hence the \\Gridfee?\\ # The name is definitely correct: for example Gridfee05.7z contains folder named Gridfee5 # But possibly made a mistake in the syntax? foreach my $file (@files) { my $extdir = '-o $base.$year\$month\$day\\'; system ('C:\Program Files\7-Zip\7z.exe',' e ',$archive,' -r',$extdir,$file,' n n') or die $!; # Many things in Perl are a mystery to me and the use of 7z via Perl is most definitely one of them # This is the syntax I have distilled from what info I could find on interaction between Perl and 7z # and from the 'Help'-file that comes with the 7zip-program # The ' n n' is my attempt at making 7zip skip the files which can already be found in $extdir say('Moved '.$file.' to '.$extdir); # Just a check to see what has been done, if anything } } } } exit 0;