Solution to rename file in a zip archive
Hi Guys,
AT developed this solution for a guy in the perl_help mailing list , he wanted a solution in perl to rename files in a zip archive.
Here is his code snippet.
#!/bin/bash # Zip filename converter script
# Copyright (C) 2008 Deepak Barua # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
#Deepak Barua is a member of the
# Linconsulo Group # contact@linconsulo.com # www.linconsulo.com
export WORKFILE=realfile export REALFILE=testfile2 export ZIPFILE=test.zip
perl -e '
use strict; use warnings;
use Archive::Zip qw( :ERROR_CODES );
my $zip = Archive::Zip->new();
$zip->read($ENV{ZIPFILE}) == AZ_OK or die "read error \n";
my $m1 = $zip->memberNamed($ENV{WORKFILE});
$m1->fileName($ENV{REALFILE}); # Renamed file
$zip->overwrite() == AZ_OK or die " Write error \n";
'
-
Archives
- April 2009 (1)
- December 2008 (3)
- November 2008 (2)
- October 2008 (20)
- September 2008 (3)
-
Categories
-
RSS
Entries RSS
Comments RSS