#!/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__
In reply to Re: After listing the folder in a directoy, i unable to zip the folders by using system command.
by Anonymous Monk
in thread After listing the folder in a directoy, i unable to zip the folders by using system command.
by perladdict
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |