Hi everybody!

Quite new to Perl, but picking it up at a steady pace.

The point of the code given below is the following: I have 7 .7z-files. The files are not that big (500 - 700 MB), but each file contains a folder which in turn contains around 2.2 million .txt-files. Needless to say, Windows/7zip are having a pretty difficult time extracting all the files from the archives (remaining time = around 1500 hours after 5% done, me and my bosses don't have that kind of time).

I'm going to give up on extracting everything and want to try only extracting the files which have not yet been extracted and putting them into the correct subfolder (which is D:\Some\Specific\Folder\Archive\yyyy\mm\dd\ - based on the date in the filenames ; these folders already exist). All this using 1 little Perl-script so I can just start it up and let it run as long as it needs to without having to worry about it anymore until it's done.

# !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 mysel +f 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','2 +6','27','28','29','30','31'); my $archive = glob qq($base.Gridfee0?.7z\\); #Tried glob qq($base.Gridfee0?.7z\\Gridfee*\\) and glob qq($base.G +ridfee0?.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 Gridfee0 +5.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 in +fo I could find on interaction between Perl and 7z # and from the 'Help'-file that comes with the 7zi +p-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 a +nything } } } } exit 0;

The code as it is right now outputs absolutely nothing, it just seems to run for a couple of seconds and then stops and I have no idea why.

Can you spot my mistakes?


In reply to Extracting files from .7z using Perl by zarath

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.