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]";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.