This will run, just create the two directories and let me know what you think, thanks for looking!
#!/usr/bin/perl -w # use strict; use CGI qw(:standard); use File::Basename; use File::stat; use File::Slurp qw(read_dir); use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); #print header(); # zip stuff::: my $zip = Archive::Zip->new(); # new instance #Archive::Zip::setChunkSize( 2000 ); #my $chunkSize = Archive::Zip::chunkSize(); my ($file_path, $file_name, $zipped, $flag,$k_size); $flag = ''; # vars my @files; # get the pdf files from here::: my @directories = qw( /var/www/test_1 /var/www/test_2); # set sizes::: my $min_size = 1024; # bytes => 1K my $max_size = 10485760; # bytes =>10MB # go in the directories::: my $c; for my $d (@directories) { $c++; push @files, grep { -f && -s _ >= $min_size && -s _ <= $max_size } + read_dir( $d, prefix => 1 ); } #get file sizes just in case::: # open (INDEXFILE, '>>log.txt'); foreach my $files(@files) { #my $size = (stat($files))[7] / 1024; # size in kilobytes my $size = stat($files)->size; $k_size = sprintf ("%03d", $size); #print "\n$files = $size - $k_size\n"; # do some clean up::: $files=~s/[\r\n]+//; if($files =~/(.*?)\/([^\/]+)$/) { $file_path=$1; $file_name=$2; } # creating log file::: open (INDEXFILE, '>>log.txt'); print INDEXFILE "$file_name - $k_size\n"; close (INDEXFILE); $zipped = $zip->addFile('log.txt')unless $zip->memberNamed('log.txt' +); foreach my $each_file (glob("$file_path/$file_name")) { $zipped = $zip->addFile($each_file,$file_name); } die $flag="Failed" unless $zip->writeToFileNamed( 'test.zip' ) == A +Z_OK; } #close (INDEXFILE); # show status::: if($flag eq "Failed") { print "\n\nError in archive creation!\n\n"; } else { print "\n\nArchive created successfully!\n\n"; }

In reply to Re^2: Zipping Files Help! by Anonymous Monk
in thread Zipping Files Help! by Anonymous Monk

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.