3

How can I automatically zip a group of files into multiple zip files (say, 2mb in size for each file), and that each zip file is a stand-alone zip file? (i.e. not mult-volume zip files, that you can't lost any one of the files, otherwise you can't unzip)

Is there any tools available to do so? Actually I just need to group the files into many groups, 2mb each etc, zipped or not zipped doesn't matter

thx!

4 Answers 4

1

Try a freeware tool called Bitser. Its free and lets you create multiple separate zip files from explorer via the context menu. Its pretty easy, just highlight the files or folders in Explorer, right click and select "Add to Separate Zip"

www.bitser.org

1
  • this is not at all what OP described
    – PsychoData
    Nov 22, 2013 at 20:38
0

You might consider putting your files in a zip archive then using Adsen File Splitter.

Edit:

Now that I think about it this probably isn't what you wanted... I leave it up anyway.

0

One technique is to create a zip file containing everything, then use the zipsplit command (part of the free/open Info-ZIP software) to split it up into appropriately sized chunks with the -n option.

That link goes to a Mac OS X manpage, but Info-ZIP's software runs on pretty much all hardware/OS combinations available since the 80s.

0

Unfortunately zipsplit does not work for files above 2GB, so I got frsutrated with the same problem. Therefore I wrote my own quick and dirty perl script, which does its work. Its adds files to the archive as long as the file + archive is lower than the max. specified size:

# Use strict Variable declaration
use strict;
use warnings;
use File::Find;

# use constant MAXSIZE    => 4700372992; # DVD File size
use constant MAXSIZE    => 1566790997; # File size for DVD to keep below 2GB limit
# use constant MAXSIZE    => 100000000; # Test

use constant ROOTDIR    => 'x:/dir_to_be_zipped'; # to be zipped directory

my $zipfilename    = "backup"; # Zip file name
my $zipfileext    = "zip"; # extension

my $counter = 0;
my $zipsize = undef;
my $flushed = 1;

my $arr = [];

find({wanted =>\&wanted, no_chdir => 1}, ROOTDIR);

flush(@{$arr});

# Callback function of FIND
sub wanted {
    my $filesize = (-s $File::Find::name);

    LABEL: {
        if ($flushed) {
            $zipsize = (-s "$zipfilename$counter.$zipfileext");
            $zipsize = 0 unless defined $zipsize;

            printf("Filesize Zip-File %s: %d\n", 
                "$zipfilename$counter.$zipfileext", $zipsize);

            $flushed = 0;

            if (($zipsize + $filesize) >= MAXSIZE) {
                $counter++;
                $flushed = 1;
                printf("Use next Zip File %d, Filesize old File: %d\n",
                    $counter, ($zipsize + $filesize));
                goto LABEL;
            }
        }
    }

    if ( $zipsize + $filesize  < MAXSIZE ) {
        printf("Adding %s (%d) to Buffer %d (%d)\n",
            $File::Find::name, $filesize, $counter, $zipsize);

        push @{$arr}, $File::Find::name;
        $zipsize += $filesize;
    }
    else {
        printf("Flushing File Buffer\n");
        flush(@{$arr});

        $flushed = 1;
        $arr = [];
        goto LABEL;

    }
}

# Flush File array to zip file
sub flush {

    # open handle to write to STDIN of zip call
    open(my $fh, "|zip -9 $zipfilename$counter.$zipfileext -@")
        or die "cannot open < $zipfilename$counter.$zipfileext: $!";

    printf("Adding %d files\n", scalar(@_));
    print $fh map {$_, "\n"} @_;
    close $fh;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .