I try to do this:
#!/usr/bin/perl -w use warnings; use strict; use Archive::Zip qw( :ERROR_CODES ); my @files; @files = <ATP.xxx*.zip>; foreach my $file (@files){ my $zip = Archive::Zip->new(); $zip->read($file) == AZ_OK or die "read error $!"; $zip->endRead($file); $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"; }
it tells me: Can't locate object method "endRead" via package "Archive::Zip::Archive" at ./ziprenamer2.pl line 12. if I do this:
#!/usr/bin/perl -w use warnings; use strict; use Archive::Zip qw( :ERROR_CODES ); my @files; @files = <ATP.xxx*.zip>; foreach my $file (@files){ my $zip = Archive::Zip->new(); $zip->read($file) == AZ_OK or die "read error $!"; #$zip->endRead($file); $file=~ s{\.[^.]+$}{}; my $m1 = $zip->memberNamed($file); $file=~s/^.{4}//s; $m1->fileName($file); $m1->endRead(); $zip->overwriteAs("$file.zip") == AZ_OK or die "write error $!\n"; }
I get the same error as before and too many files open
at /usr/share/perl5/Archive/Zip/FileMember.pm line 40 Archive::Zip::FileMember::_openFile('Archive::Zip::ZipFileMemb +er=HASH(0x257b610)') called at /usr/share/perl5/Archive/Zip/FileMembe +r.pm line 30 Archive::Zip::FileMember::fh('Archive::Zip::ZipFileMember=HASH +(0x257b610)') called at /usr/share/perl5/Archive/Zip/ZipFileMember.pm + line 381 Archive::Zip::ZipFileMember::rewindData('Archive::Zip::ZipFile +Member=HASH(0x257b610)') called at /usr/share/perl5/Archive/Zip/Membe +r.pm line 1063 Archive::Zip::Member::_writeToFileHandle('Archive::Zip::ZipFil +eMember=HASH(0x257b610)', 'IO::File=GLOB(0x257ba60)', 1, 0) called at + /usr/share/perl5/Archive/Zip/Archive.pm line 420 Archive::Zip::Archive::writeToFileHandle('Archive::Zip::Archiv +e=HASH(0x242d8f8)', 'IO::File=GLOB(0x257ba60)') called at /usr/share/ +perl5/Archive/Zip/Archive.pm line 456 Archive::Zip::Archive::overwriteAs('Archive::Zip::Archive=HASH +(0x242d8f8)', 'ROUTINGS.D150313.T1600.zip') called at ./ziprenamer2.p +l line 17 Can't write to /tmp/2PMKA29PUY.zip at ./ziprenamer2.pl line 17 write error Too many open files
and only about 1000 files are processed Note I just have to do it once.. the next times I only have to rename the last one arrived.. it will be set as a cron job.

thank you.


In reply to Re^4: rename zip files and folders inside zip files by mariog
in thread rename zip files and folders inside zip files by mariog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.