How to zip a big folder into small files limited to 20Mb?

In winzip: Add the files to the zip either by starting up winzip and adding or drag and drop into winzip or right click on the files and winzip 'add to zip...'

Then in winzip:

Actions - Split at the bottom of 'part size' pick 'other size' then put 20 and select mb

Done!


Letting zip do the splitting for you will be much easier to automate than trying to figure it out by yourself. If your goal is 20MB zip files, you will have to estimate the compressed size of each file before adding it to the archive. Is there a reason you don't want to just let zip do the splitting for you? Here's how you'd do it with gnu zip:

zip -s 20m -r myzip.zip mydir

This will create 20MB zipped files with incremental index numbers in the filename.


What you're proposing is essentially a variation of the Knapsack Problem, with the added twist that, due to file compression, you don't start off knowing how much of your 20MB "knapsack" each item will occupy.

The trivial solution, of course, would be to simply zip each file independently, but that fails to reduce the file count any, so I suspect it would not be a satisfactory solution.

If I were presented with this problem, I suppose I would start out by compressing each file individually to a temporary location (or in memory, without writing them to disk), just so that I could get an approximate compressed size for each. With that information, it would then be possible to decide which files should be grouped together by any of the standard approaches to the Knapsack Problem and create the actual zip files.

Assuming you have a scripting language available to you and you know how to use it, I would expect this approach to be fairly straightforward to automate; doing it manually would be quite tedious if you have more than a handful of files to deal with...


On Linux there is a program named zipsplit that does exactly this. It's part of the standard zip package.

It can be run like this:

zipsplit bigfile.zip -n 20000000

to split bigfile.zip into parts of max 20MB. And note that individual contained files will not be split. Thus each part can be individually unzipped. Which also means that if there is a single file that can't fit into the max part size the splitting will not be possible.

Update: It seems that there are also binaries for Windows at info-zip.org, specifically in ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn-x64.zip for Win 64.