Hello,
I have the code below which unzips a series of zip files.
I would like to be able to change the names of the Word files produced
to more systematic names.
Say doc-1.zip produces fred.doc
and
doc-2.zip produces jane.doc
I would like to change
fred.doc to doc-1.doc
and
jane.doc to doc-2.doc
You can that see I want to keep the number which the original zip file had. This is because I want to replace a whole series of zip files on a website with the Word files inside them.
Ideas please?!
Thanks
Geoff
#!perl
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use File::Find;
my $dir = 'c:/a-temp';
my @zips;
find sub {
-d and return;
/\.zip$/ and push @zips, [$File::Find::dir, $_];
}, $dir;
my $zip = Archive::Zip->new;
for (@zips) {
chdir $_->[0] or die "can't chdir to $_->[0]: $!";
$zip->read($_->[1]) == AZ_OK or die "can't read _->[1]";
$zip->extractTree == AZ_OK or die "can't extract $_->[1]";
}