2

I need weekly to upload bunch of pdf file to grading platform, in the form of zip, but the website has limit of 250Mb per zip file, and it takes me too much time to split the zip I have into smaller zip files.

What is the simplest way to split a zip into chunks with max size?

A way that would work on other unix-like platform (like my mac at work) will be grate.

I'm looking an existing command that will do it, or some simple python (or node, or any other simple to use languages) module that will help we write a small script that does it.

  • 1
    I think this might be useful https://superuser.com/questions/336219/how-do-i-split-a-zip-file-into-multiple-segments – Inmate4587 Jan 04 '19 at 12:17

1 Answers1

5

You need zipsplit which is part of the zip package:

zipsplit -n $(( 250 * 1024 * 1024 )) your_zipfile.zip

It splits an existing zipfile into smaller chunks. The size of each chunk can be supplied via the -n switch. It defaults to 360000 because years ago floppy disks had a capacity of 360 kB.

Another option would be to create the chunks in the first place while zipping (see zip, especially the -s switch) and thus avoiding the separate zipsplit step:

zip -s 250m new-zipfile file1 file2 file3...

Unfortunately unzip new-zipfile.zip cannot handle the chunks created via zip -s so you have to join them on the target side before unzipping:

zip --fix new-zipfile --out joined-zipfile
unzip joined-zipfile
PerlDuck
  • 13,335
  • the files created will be real zip file of chunks (means that later on I will need to put them together) of the original one? If my original file contains f1.pdf (25MB) ,f2.pdf (20MB) and f3.pdf (8MB) and the limit is 50MB per zip file I want the output to be two zip files, one with f1.pdf and f2.pdf and one with f3.pdf. – Barak Ohana Jan 04 '19 at 13:45
  • 1
    @BarakOhana zipsplit will create a number of stand-alone zipfiles each of which can be unzipped on its own (no joining needed). zip -s on the other hand creates a number of files that must be joined via zip --fix because unzip cannot currently handle these files. I'd go with zipsplit in your case. – PerlDuck Jan 04 '19 at 14:37
  • As a note, this method doesn't work if archive contains a file that is larger than desired chunk size – user502144 Jan 14 '21 at 07:53
  • Thanks for the clarification of independent extraction. I'm trying to handle my large zip files from exporting videos from iCloud. – Sridhar Sarnobat Apr 03 '21 at 21:15
  • Great answer - helped explain the units used in the -n argument – naaman Mar 14 '22 at 06:28