|
hi,
i have created a code to unzip the zip files to a particular destination
It is unzipping but it is skipping directories inside the zip file
what should i do. I have pasted my code
# Script to unzip the zip files to a particular destination creating the folder with the name of zip file
use Archive::Zip;
use Archive::Tar;
use File::Copy;
use File::Find;
use File::Basename;
my @ext;
find(\&search, "D:/aaa");
sub search
{
if ((/\.zip$/) )
{
push @ext, $File::Find::name;
#print "@ext\n";
}
}
my @name1;
foreach my $fname(@ext)
{
my ($name, $path, $suffix) = fileparse($fname, '\.[^\.]*');
my $n = "D:/a/";
my $name1 = join("/index.html",$n,$name);
# Making folder with the name of the zip file found
mkdir $name1,0755;
print "\n\n Made Folder ";
print STDOUT $name, "\n";
my $zipname = $fname;
my $destinationDirectory = $name1;
my ($archive, $want, $dir) = shift;
my $zip = Archive::Zip->new($zipname);
foreach my $member ($zip->members)
{
next if $member->isDirectory;
(my $extractName = $member->fileName) =~ s{.*/}{};
$member->extractToFileNamed("$destinationDirectory/$extractName");
}
print "\n Extraction Completed.............";
}
Thanks in Advance
Avi
|
|
|
|
|
|
|
// |