473,386 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problem in extracting the zip files

hi,

I have created a script in perl to extract n number of zip files to a particular destination after creating the folder of the zip file.

It is extracting . But when the zip file has subdirectories or folders inside it it ignores that and eztracts the whole contents without making folders

what shout it do I am using activeperl in Windows XP

i have pasted the code

Expand|Select|Wrap|Line Numbers
  1. # Script to unzip the zip files to a particular destination creating the folder with the name of zip file
  2.  
  3. use Archive::Zip;
  4. use Archive::Tar;
  5. use File::Copy;
  6. use File::Find;
  7. use File::Basename;
  8.  
  9. my @ext;
  10.  
  11. find(\&search, "D:/aaa");
  12.  
  13. sub search
  14.  {
  15.      if ((/\.zip$/) )
  16.      {  
  17.         push @ext, $File::Find::name;
  18.         #print "@ext\n";    
  19.      }
  20.  }
  21.  
  22. my @name1;
  23. foreach my $fname(@ext)
  24. {
  25. my ($name, $path, $suffix) = fileparse($fname, '\.[^\.]*');
  26.  
  27. my $n = "D:/a/";
  28. my $name1 = join("/",$n,$name);
  29. mkdir $name1,0755;
  30.  
  31. print "\n\n Made Folder ";
  32. print STDOUT $name, "\n";
  33.  
  34. my $zipname = $fname;
  35.  
  36. my $destinationDirectory = $name1;
  37.  
  38. my $zip = Archive::Zip->new($zipname);
  39. foreach my $member ($zip->members)
  40. {
  41.     next if $member->isDirectory;
  42.     (my $extractName = $member->fileName) =~ s{.*/}{};
  43.     $member->extractToFileNamed("$destinationDirectory/$extractName");
  44. }
  45. print "\n Finished Extraction";
  46. }
  47.  
Thanks in Advance
Avi
Sep 28 '07 #1
2 1963
KevinADC
4,059 Expert 2GB
looks like your code is skipping directories:

next if $member->isDirectory;

remove or rem the above line and try again.
Sep 28 '07 #2
looks like your code is skipping directories:

next if $member->isDirectory;

remove or rem the above line and try again.
hi,

i tried by removing the line but it is still giving the same problem


what should i do

Thanks
Avi
Sep 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Nazgul | last post by:
Hi! I want to implement a small tool in Python for distributing "patches" and I need Your advice. This application should be able to package all files chosen by a user into a self-extracting.exe...
3
by: wenz | last post by:
Hi I have an exe which is actually a self-extracting zip file that i would like to run to extract all the files. I have the code showing how to use the j# classes and library to extract zip files...
0
by: k_nil | last post by:
I have a link on my web page for a self extracting executable file placed on the server. When the link is clicked, 1) i could see dialog box with open or save options 2) when open clicked, self...
5
by: steve_marjoribanks | last post by:
This isn't strictly an XML problem but I thought someone might be able to help! As part of my degree I am working on a new data format for use in the geotechnical engineering domain. The data...
1
by: Hari Sekhon | last post by:
Hi, I've written a script to run on windows to extract all zips under a given directory path to another directory path as such: python extractzips.py <fetch all zips under this dir> <put all...
2
by: Robert McEuen | last post by:
Sorry if this double-posts...Google doesn't do a very good job of communicating whether something has posted or not. Using Access 97, WindowsXP Is there a way to pass command line parameters...
6
by: rlntemp-gng | last post by:
I need to extract information from some Excel files but am stuck with part of it: As an example, I have the following Excel File that has 3 tabbed sheets: FileName: ...
6
by: Werner | last post by:
Hi, I try to read (and extract) some "self extracting" zipefiles on a Windows system. The standard module zipefile seems not to be able to handle this. False Is there a wrapper or has...
4
by: Ant | last post by:
Hi all, My kids have a bunch of games that have to be run from CD (on Windows XP). Now they're not very careful with them, and so I have a plan. I've downloaded a utility (Daemon Tools) which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.