This is my code so far, I'm continuing to work on it, and will post as I make major steps forward:
#!/usr/bin/perl use strict; use diagnostics; use File::Path; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); ############################################ # Prints the usage file if requested or if # # called incorrectly # ############################################ if (@ARGV != 1 || $ARGV[0] eq '--help'|| $ARGV[0] eq '-help' || $ARGV[0] eq '?') { &printUsage; #Ommited for ease of review } # These variables store the locations of # the directory containing the zip # Files to be tested, as well as the # location of the processed and error # files. my $basePath = "C:/DocumentQC/Document Manipulation Area/Zip Test"; my $inputDirectoryName = "Input"; my $outputDirectoryName = "Output"; my $inputDirectory = "$basePath/$inputDirectoryName/"; my $outputDirectory = "$basePath/$outputDirectoryName/"; # Checks to see if all necessary directories # exist, and creates them if they don't. my $outputDirectoryExists = 0; opendir(PARENT_DIRECTORY, $basePath) || die ("Cannot open directory, m +ake sure you've edited the $basePath variable in breakUpZipFiles1_0_0 +.pl."); my @parentDirectoryArray = readdir(PARENT_DIRECTORY); closedir(PARENT_DIRECTORY); for my $i (0 .. $#parentDirectoryArray) { if ($parentDirectoryArray[$i] eq $outputDirectoryName) { $outputDirectoryExists = 1; } } if ($outputDirectoryExists == 0) { mkdir("$basePath/$outputDirectoryName", 0755); } # Opens the input directory and reads all files # to the @input array. opendir(INPUT_DIRECTORY, $inputDirectory) || die("Cannot open input di +rectory $inputDirectory - $!"); my @input = readdir(INPUT_DIRECTORY); closedir(INPUT_DIRECTORY); # Do the nasty! #YOU MAY NEED Archive::Zip::setChunkSize( 4096 ); TO DEAL WITH THESE L +ARGE FILES my $fileIterator = 1; my $zeroFill = "000"; #change later to fill properly MAIN_LOOP: for (my $i = 0; $i < @input; $i++) { #-------------------------------# # Ignore if it isn't a zip file # #-------------------------------# if ($input[$i] !~ /^(.*)\.zip$/) { print "\nSKIP FILE: \t\t$input[$i]"; next MAIN_LOOP; } print "\nARCHIVE ENCOUNTERED: \t$input[$i]"; my $baseFileName = $1; #--------------------------------------------------# # Create a zip object for the file to break apart, # # and a zip object for your smaller archive # #--------------------------------------------------# my $inputZipFile = Archive::Zip->new(); unless ( $inputZipFile->read("$inputDirectory$input[$i]") == AZ_OK) +{ die "Error reading zip file: $input[$i]"; } my $outputZipFile = Archive::Zip->new(); #------------------------------------------------------# # Create a list of the files in the current zip object # #------------------------------------------------------# #---------------------------------------------------# # Add files from the old zip object sequentially to # # the new zip object, delete it from the old one # #---------------------------------------------------# # USE Archive::Zip::MemberRead (Page 4) #-----------------------------------------------------# # Iterate until there are 250 files in the new object # #-----------------------------------------------------# #---------------------------------------------------------# # Zip the new object and place it in the pickup directory # #---------------------------------------------------------# unless ( $outputZipFile->writeToFileNamed("$outputDirectory$baseFile +Name\_$zeroFill$fileIterator\.zip") == AZ_OK) { die "Error reading zip file: $input[$i]"; } #------------------------------------------------------------------# # If there are no more files in the old zip directory, destroy it # #------------------------------------------------------------------# }

In reply to Re^3: Breaking up ZIP files by jared.collier
in thread Breaking up ZIP files by jared.collier

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.