Search the web
Sign In
New User? Sign Up
Perl_Official · Perl . CGI . Shell script
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Want to lear Perl   Message List  
Reply | Forward Message #2050 of 2062 |
Unzipping the zip file



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 "@ext\n";
}

}

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]




Thu Sep 27, 2007 11:51 am

avik1612
Offline Offline
Send Email Send Email

Forward
Message #2050 of 2062 |
Expand Messages Author Sort by Date

Hi, I want to leanr Perl, can anyone tell me where can i get resources for the same. Thanks a lot Sujay...
sujaymallesh
Offline
Aug 1, 2007
5:41 pm

... sujaymallesh> I want to leanr Perl, can anyone tell me where can i get resources for sujaymallesh> the same. A bit of googling should have brought you to...
merlyn@...
merlynstoneh...
Offline Send Email
Aug 1, 2007
8:36 pm

... for ... How do you lear or leanr Perl? Your best offline resource for learning Perl would be: Programming Perl 3rd edition by Larry Wall, Tom Christiansen,...
Yogesh Sawant
yoga_sawant
Offline Send Email
Sep 12, 2007
8:42 pm

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...
avinash k
avik1612
Offline Send Email
Sep 27, 2007
10:30 pm

If you are completely new to scripts and programs then, PERL in 21 days might help you.. just PRACTICE it before going to Programming PERL - Larry Wall .. ...
Shreedhar
ps_dhar2000
Offline Send Email
Oct 2, 2007
10:14 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help