2005-12-07: Updated regular expression per Celada's input below.#!C:\Perl\bin\perl.exe -w use File::Find; use Archive::Zip qw( :ERROR_CODES :CONSTANTS); use Cwd; my $dir = cwd(); print "Zipping .tif, .tiff, and .eps files...\n$dir\n\n"; find(\&edits, $dir); sub edits() { my $filename = $_; if (-f and ( /\.tiff?$/ or /\.eps$/ )) { print "$File::Find::name\n"; my $barefile = $filename; substr( $barefile, rindex( $barefile, '.' ) ) = ''; if ($barefile ne '') { my $zip = Archive::Zip->new(); my $member = $zip->addFile($filename); if ($zip->writeToFileNamed("$barefile.zip") == AZ_OK) { unlink($File::Find::name) } else { die 'Error writing file'; } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Zip all .tif and .eps files
by Celada (Monk) on Dec 06, 2005 at 19:44 UTC | |
by buttroast (Scribe) on Dec 07, 2005 at 15:35 UTC | |
|
Re: zip_all for .tif & .eps
by Scott7477 (Chaplain) on Dec 30, 2005 at 14:09 UTC | |
by buttroast (Scribe) on Jan 03, 2006 at 18:02 UTC |