in reply to Re^2: Create zip files for each sub-directory under a main directory
in thread Create zip files for each sub-directory under a main directory
I was able to get rid of the MKV zip file. Forgot a couple of lines that stevieb had suggested.
New code is:
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 "$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"; }
Still trying to figure out how to remove the partial directory structure within the apxxxx.zip files
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Create zip files for each sub-directory under a main directory
by mrd1019 (Novice) on Nov 30, 2016 at 18:17 UTC |