I have tried zipping a directory which contains sub directories and files and this is my code.
!/usr/bin/perl -w use strict; use List::Util qw(first); use Archive::Zip qw(:ERROR_CODES :CONSTANTS); my $input= 'D:\temp\sample'; my $outDir = 'D:\out\sample.zip'; my $obj = Archive::Zip->new(); $obj->addTree( $input ); # # Write the files to zip. if ($obj->writeToFileNamed($outDir) == AZ_OK) { # write to disk print "\n\nArchive created successfully!\n"; } else { print "Error while Zipping !"; }
When i execute this, the zip file ( sample.zip ) is created.
Always the unzipping is done manually selecting the option " Extract Here ".
When i unzip this , the directory bursts open putting all the subfolders and files at the same location( D:\out).
What i want is, i expect the output to be a unique folder ( D:\out\sample) So, what changes need to be done in my code. Pls help me.
In reply to How to zip the directory in a required format by sanvin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |