I GOT IT!!!!! (Sorry, very happy right now). Once I added in the next if statements, and had set to chdir, I made one last change, and the code now works as I want it to!

Once again, a HUGE thank you to everyone that assisted!! Looking forward to continuing my journey here with perl.

Newest code, in case anyone is wondering:

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; next if $dir =~ /(?:\.|\.\.)/; next if $dir eq $mkvingestdir; print “Now processing directory $dir\n”; my @files = glob "*.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^4: 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.