in reply to Re: Create zip files for each sub-directory under a main directory
in thread Create zip files for each sub-directory under a main directory
So, I initially tried Stevieb's suggestion. It created the zip files, but there were no files inside the zip. So, I started playing. Again, I'm getting the zip files created, with the correct names, but there are no files inside the zips. Here is the latest attempt that I made at this:
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/data/nonops/common/engine/ingest/sim/mkv”; my $mkvingestdest = “//nas/shared/group/test/mkv/ingest”; my @dirs = File::Find::Rule->directory() ->in($mkvingestdir); my @files; foreach my $dir (@dirs) { @files = glob "*.eap"; my $mkvingestzip = Archive::Zip->new(); foreach $_ (@files) { $mkvingestzip->addFile($_); } my $name = basename $dir; if ($mkvingestzip->writeToFileNamed("$mkvingestdest/${name}.zip") + != AZ_OK) { print "Error in archive creation\n"; next; } print "Archive created successfully!\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Create zip files for each sub-directory under a main directory
by hippo (Archbishop) on Nov 29, 2016 at 21:24 UTC | |
|
Re^3: Create zip files for each sub-directory under a main directory
by kcott (Archbishop) on Nov 29, 2016 at 21:52 UTC | |
|
Re^3: Create zip files for each sub-directory under a main directory
by stevieb (Canon) on Nov 29, 2016 at 22:09 UTC |