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...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

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
problem in extracting the zip file   Message List  
Reply | Forward Message #2051 of 2062 |
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 "@ext\n";
}

}

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 "\n\n 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]




Fri Sep 28, 2007 9:34 am

avik1612
Offline Offline
Send Email Send Email

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

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...
avinash k
avik1612
Offline Send Email
Oct 2, 2007
10:12 pm
Advanced

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