List Info

Thread: problem in extracting the zip file




problem in extracting the zip file
country flaguser name
India
2007-09-28 04:34:21

Hi,

I have created a script to extarct a set of zip files in a particular folder to another destination . In the destination folder a folder would be created with the name of zip file and it would be extracted in that folder with the name of zip file.

It is working well but when the zip file have subdirectories i.e folder inside folder. It in ignore the subdirectory and extract the whole contents into a single folder

What is wrong with my code

i have pasted the code for ur reference

# 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 "extn";
}

}

my name1;
foreach my $fname(ext)
{
my ($name, $path, $suffix) = fileparse($fname, '.[^.]*');

my $n = "D:/a/";
my $name1 = join(";/",$n,$name);
mkdir $name1,0755;
print "nn Made Folder ";
print STDOUT $name, "n";

my $zipname = $fname;

#my $destinationDirectory = 'D:a';
my $destinationDirectory = $name1;

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 Finished Extraction";
}

Thanks in Advance
Avi

---------------------------------
Unlimited freedom, unlimited storage. Get it now

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )