List Info

Thread: Unzipping the zip file




Unzipping the zip file
country flaguser name
India
2007-09-27 06:51:48



Hi,
I have to create a script to read a zip files of a folder and then extract all those zip files to another destination
inside a folder created with the name of the zip file
for e.g if the zip file is in D:/ab.zip then it should be extracted to D:/a/ab where ab is the folder created with the
name of the zip file

I have pasted the code till how much i have tried what should i do further

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, '.[^.]*');
print STDOUT $name, "n";
}
print $name;
my $n= "D:/a/";
my $name1= join(";/",$n,$name);
print name1;
print $name;

mkdir $name1, 0755;
foreach my $in (ext)
{
open(IN, $in) || die " cannot open the file";
while(<IN>)
{
my $zipname = $_;
my $destinationDirectory = 'D:a';
my $zip = Archive::Zip->new($zipname);
foreach my $member ($zip->members)
{
next if $member->isDirectory;
(my $extractName = $member->fileName) =~ s{.*/}{};
$member->extractToFileNamed("$destinationDirectory/$extractName");
}
}
close(IN);
}

thanks in advance
avi

---------------------------------
5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.

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

__._,_.___
.

__,_._,___
[1]

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