Hello, I have a directory with the following structure: nas\data\nonops\common\engine\ingest\sim\mkv\ap0000->files

\ap0001->files

…………..

\ap1335->files

For archiving purposes, I need to create a zip file at the end of tests (when the apxxxx folders are populated). This is my current code. It copies all the directories under nas\data\nonops\common\engine\ingest\sim\mkv into the destination, then creates one zip file out of all of that. The issue is that there is so much data total in all the sub-directories that it is too big to make one zip file. I need to be able to create a separate zip file for each apxxxx file, ideally naming each zip file as apxxxx.zip.

use strict; use warnings ‘all’; use File::Copy::Recursive; use Archive::Zip; use constant AZ_OK =>0; my $mkvingestdir = “//nas/data/nonops/common/engine/ingest/sim/mkv”; my $mkvingestdest = “//nas/shared/group/test/mkv/ingest”; File::Copy::Recursive::dircopy $mkvingestdir, $mkvingestdest or die “C +opy failed: $!\n”; my $mkvingestzip = Archive::Zip->new(); my $mkvingestzipdest = “//nas/shared/group/test/mkv”; $mkvingestzip ->addTree($mkvingestdest); if ($mkvingestzip->writeToFileNamed(‘ingest.zip’) != AZ_OK) { print “Error in archive creation!\n”; } else { print “Archive created successfully!\n”; }

I’m thinking a foreach loop would work? I’m not 100% sure how to go about getting to my end goal. The script above works, but will not work when a full test is ran and there is 10 – 20 GB of data total in the /mkv directory. Any help would be greatly appreciated!


In reply to Create zip files for each sub-directory under a main directory by mrd1019

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.