Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

renaming zipped files.

Status
Not open for further replies.

tar565

Programmer
Jan 24, 2005
39
0
0
IE
I am unzipping 2 logfiles from 2 different server. One file is name serverA.zip and the other server2.zip. However there is 1 file inside each which is always named by the date and both are the same (ie the file inside both zip files have the same name).

How can I rename them to avoid a conflict when I extract the 2nd file. I am extracting each file as follows.

Can I use rename()???

Here is my zip code.

#################################

my $zip = Archive::Zip->new();
$zip->read(@_);
for($zip->members()) {
$zip->extractMember($_);
$extracted = 1;
}
return $extracted;

#####################################
 
You could always extract the content of each file to a scalar and write it to a file manually (open, print, close) with whatever filename you want to create.
 
per documentation, extractMember can take two arguments, the second being the local filename of the file once extracted. So, you just check the member name inside the loop to see if it's your problem file and give that one a different name.

________________________________________
Andrew

I work for a gift card company!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top