15

I'm looking for way to zip a big folder into many 20Mb files. I don't want the zip file split into smaller ones. Instead I want to group some sub files/folders into groups which is 20Mb when zipped.

If you know how to do so, please help!

Update

I need to use the smaller zipped files alone which are able to be unzipped alone.

My intention is to use virustotal.com to scan a big folder.

Nam G VU
  • 12,548

8 Answers8

11

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!

adolf garlic
  • 2,155
9

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.

SethG
  • 201
6

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...

4

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.

Zitrax
  • 555
3

Not an easy prospect I'm afraid.

I recently wrote a script to gather files into subdirectories not larger than 4.3GB for easy storage on DVD, but this was all uncompressed.

Doing it with compression - now there's the challenge. You can't predict the size of the files after compression - all you could do is keep adding files to the zip in descending order of size until it exceeds 20MB and then remove the last file replacing it with a smaller one until it drops below 20MB. If you exhaust all the files and it's still >20MB then just drop the last file and move on to the next zip.

Quite a tricky bit of scripting and a rather slow, painful, process.

Majenko
  • 32,964
2

I know this is an old thread, but I just did this with 7-zip.

You need to use the "Split to Volume" option:

enter image description here

2

Dave seemed to provide the closest programmable solution to what OP requested. I figured out that this could be done manually as well, if the following assumptions are taken (this is not a pure technical problem–it is more of an organizational problem than technical):

  1. Since the OP requires that each zip file should be able to extract all its contents independently, files that surpass 20 MB after zipping must be handled in one of the following ways:
    • they are not to be considered, and therefore must be separated;
    • they need to be split into 20MB volumes, as other answers suggested (winzip, 7-zip), and the resulting files cannot be used independently (breaking this 1st assumption).
  2. The zipped files do not necessarily need to have exactly 20MB.
  3. If it is more important to have several zip files with the approximate 20MB size, then zipping can be done without compression.

By using this method with 7-zip (Windows' interface and terminal) I preserved the compression in the newly generated zip files.

Start by zipping all the files into a single zip file in an empty folder (with your desired compression method), e.g. ALL.zip, and open it:

  1. Order the list of files and folders by clicking on the size or packed-size (compressed) column;
  2. Start from the smallest sizes and select files/folders that you want to group into a zip;
  3. Press the Test button to confirm their collective size (this considers their compression): Test feature
  4. Press the Extract or Copy button while adding to the end of the extraction path a new folder's name (e.g.: plu_8MB)
  5. Inside ALL.zip zip, delete these files you just extracted (avoiding mistaken re-extractions) and navigate to the next folder or subset of files;
  6. Repeat one of the following:
    • steps 1 to 5 if you plan to create an independent zip file;
    • steps 1 to 3 and reuse the same folder name (step 4) until their collective sizes are approximately 20MB;
  7. Once you have extracted all the contents of ALL.zip into independent folders, delete that zip, and open the terminal in that folder;
  8. Type:

    for /F %i in ('dir /b') do "C:\Program Files\7-zip\7z.exe" a -tzip %i.zip %i
    

    Press ENTER and this will generate a zip file for each folder that you just extracted.

CPHPython
  • 567
0

http://lars.werner.no/?page_id=2

This is an old product I found searching around the web.

It might work. Make sure to select custom size of 20m on the right hand side of the window.

cybernard
  • 14,924