muizelaar has asked for the wisdom of the Perl Monks concerning the following question:
Writing the below test script for a Window 2008 server but seem to be having a few issues.
I need to add a folder and all the folders below it to a Zip Archive and produce a list of all folders below the parent. I can list the output and create the Archive Zip file but it doesn’t seem to want to add the folders to the Zip file.
Any help would be appreciated.#!/usr/bin/perl -w use diagnostics; use File::Basename; use Cwd; my $dir = getcwd; use Archive::Zip qw/ :ERROR_CODES :CONSTANTS/; open (LOG, ">>ziplog.txt"); #Directory to be backed up my $sourcedir = 'temp'; #Location of where to backup and compress file to. my $zipfile = 'test.zip'; my $zip = Archive::Zip->new(); opendir(FH, $sourcedir); @backlist = grep { !/^\.\.?\z/ && -e "$sourcedir/$_" } readdir + FH; foreach my $file(@backlist) { print(LOG "$file\n"); } $zip->writeToFileNamed($zipfile); $zip->addTree( 'temp', 'tempfolder' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Archive Zip
by Corion (Patriarch) on Jan 18, 2012 at 14:30 UTC | |
by muizelaar (Sexton) on Jan 18, 2012 at 15:28 UTC | |
|
Re: Archive Zip
by Lotus1 (Vicar) on Jan 18, 2012 at 15:18 UTC |