mariog has asked for the wisdom of the Perl Monks concerning the following question:
Hello
I have to rename the file inside a zip archive as well as the zip archive itself. the zip file and folder is called ATP.xxxxxx.zip and a file inside the zip is called identically ATP.xxxxx and I need to rename both the zip and the file inside the zip and remove the "ATP."
I tried this code but it does not workthe zip file cannot be read..#!/usr/bin/perl -w use warnings; use strict; use Archive::Zip qw( :ERROR_CODES ); my @files; @files = <ATP.xxxxxx*.zip>; foreach my $file (@files){ my $zip = Archive::Zip->new(); $zip->read('$file') == AZ_OK or die "read error $!"; $file=~ s{\.[^.]+$}{}; my $m1 = $zip->memberNamed('$file'); $file=~s/^.{4}//s; $m1->fileName('$file'); $zip->overwriteAs('$file.zip') == AZ_OK or die "write error $!\n" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: rename zip files and folders inside zip files
by toolic (Bishop) on Aug 27, 2015 at 13:06 UTC | |
|
Re: rename zip files and folders inside zip files
by GotToBTru (Prior) on Aug 27, 2015 at 13:12 UTC | |
by mariog (Acolyte) on Aug 27, 2015 at 14:24 UTC | |
by toolic (Bishop) on Aug 27, 2015 at 14:33 UTC | |
by mariog (Acolyte) on Aug 31, 2015 at 10:19 UTC | |
by graff (Chancellor) on Sep 04, 2015 at 04:08 UTC | |
by mariog (Acolyte) on Aug 28, 2015 at 11:55 UTC | |
by graff (Chancellor) on Aug 29, 2015 at 04:30 UTC | |
|