Thanks for all the help guys! I'm new to perl, been trying to teach myself via websites like this and books. Nothing compares to having experienced users help out though!

I've updated the code, based on a lot of the advice I've been given. The code now creates the zip files correctly (correct name with all the files inside). There are still a couple of things I'd like to change though. First, it creates a zip file of the top level directory (mkv in the $mkvingestdir). I don’t need that zip file. Additionally, the apxxxx.zip files don’t contain just the files, but also contain the directory path (i.e., inside the zip it is not just the .eap files, but mine/MKV/apxxxx/files).

How would I go about eliminating the MKV zip file that is created, and limit the zip’s to only have the files, and not the directory structure?

As for the single vs. double quotes that Anonymous mentioned…..as I said, I’ve been learning via websites for the most part, and I see all these different examples. I feel like I’m starting to understand the basics of perl, but there is always so much to learn. I know this code is not perfect, but I’m continually reading/studying to try and make it, and myself better. I really want to thank everyone for all the help with this.

Having said all that, here is my code as it stands now

use strict; use warnings ‘all’; use File::Copy::Recursive; use Archive::Zip; use constant AZ_OK =>0; use File::Basename; use File::Find::Rule; my $mkvingestdir = “//nas/shared/mine/MKV” my $mkvingestdest = “//nas/shared/group/test/mkv/ingest”; my @dirs = File::Find::Rule->directory() ->in($mkvingestdir); foreach my $dir (@dirs) { chdir $dir; print “Now processing directory $dir\n”; my @files = glob "$dir/*.eap"; my $mkvingestzip = Archive::Zip->new(); foreach $file (@files) { $mkvingestzip->addFile($file); } my $name = basename $dir; if ($mkvingestzip->writeToFileNamed("$mkvingestdest/${name}.zip") + != AZ_OK) { print "Error in archive creation\n"; next; } print "Archive created successfully!\n"; }

In reply to Re^2: Create zip files for each sub-directory under a main directory by mrd1019
in thread 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.