Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: After listing the folder in a directoy, i unable to zip the folders by using system command.

by Anonymous Monk
on May 21, 2013 at 22:22 UTC ( [id://1034627]=note: print w/replies, xml ) Need Help??


in reply to After listing the folder in a directoy, i unable to zip the folders by using system command.

#!/usr/bin/perl -- use strict; use warnings; #~ use autodie qw/ chdir system /; use autodie; use Win32::ShellQuote qw/ quote_system quote_system_cmd /; use File::Find::Rule qw/ find /; use File::Which qw/ which /; Main( @ARGV ); exit( 0 ); sub Main { 2==@_ or die "Usage: $0 dirtobackups prefix\n"; my( $dir , $prefix ) = @_; chdir $dir; ## or dies on its own my @folders = find( directory => maxdepth => 1, in => [ '.' ] ); shift @folders if $folders[0] eq '.'; ## Grrr for my $folder ( @folders ){ my $source = $folder; my $destination = "$prefix.$folder"; zip( $destination , $source ); } } our $infozip; sub zip { my( $destination, $source ) = @_; unless( defined $infozip ){ $infozip = which( 'zip.exe' ); if( $infozip ){ my $izv = quote_system_cmd( $infozip, '--version' ); if( not qx{$izv} =~ m{Info-ZIP} ){ $infozip = ''; die "can't find Info-ZIP zip.exe" } } } $infozip or die "no zip.exe"; $destination =~ s/(?:\.zip)?$/.zip/i; system quote_system( $infozip, '-r', '-v', '-9', $destination, $source ); } __END__

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1034627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found