Home » Questions » Computers [ Ask a new question ]

How to combine / merge zip files?

How to combine / merge zip files?

For the last several months I have copied several data folders to zip files at weekly intervals. Now I'd like to combine those zip files into one zip file, because most of the contents of the existing zip files are just different versions of the same data files.

Asked by: Guest | Views: 274
Total answers/comments: 4
bert [Entry]

"you won't like it but: unzipping everything into a working folder in the right order, then zipping the result is the most effective way.

otherwise, you will end up with a lot of wasted CPU cycles:

assume your result goes to 'first.zip'
every file from '2.zip', '3.zip' etc has to be unzipped and then zipped again into 'first.zip'
in '2.zip' exists a file 'foobar.txt' and in '3.zip' exists another file 'foobar.txt'.
merging it the way you want to merge it leads to 'compress it X times'
the toc of a .zip is at the end of the file: you add more content (to the middle of the
.zip by updating a file in the middle) and the whole file has to be rewritten

so, imho just use 'unzip' wiseley:

% mkdir all
% for x in *.zip ; do unzip -d all -o -u $x ; done
% zip -r all.zip all

the order of the unzipping is important, I don't know the pattern of your zip names, but I would extract the newest zip file first, the '-u' option of unzip overwrites only files if they are newer or creates files if not already there. as a result, you will unzip only the newest files and zip the result only once."
bert [Entry]

"Just use the -g option of ZIP, where you can append any number of ZIP files into one (without extracting the old ones). This will save you significant time.

Also have a look at zipmerge"
bert [Entry]

"If I remember correctly, pkzip was a command-line program.

There's still a command-line version of ZIP which claims to be compatible with pkzip.

It's called Info-ZIP and there should be a version for your OS."
"If I remember correctly, pkzip was a command-line program.

There's still a command-line version of ZIP which claims to be compatible with pkzip.

It's called Info-ZIP and there should be a version for your OS."
bert [Entry]

"Look for winzip command line on the net. Winzip has several versions of command line tools to fit whatever version of winzip you may may have installed. The command line tool WZZIP has a -f ""freshen"" option that will zip newer files only of those that match the name of a file in the summation output zip file.

Use WZunzip wraped in a FOR statement as shown above to unzip one file to a directory then WZzip -f to add those files to an output summation zip file. Then the FOR loop repeats to work on the next input file to output to the one and only summation output file. The order of the input files does not matter since WZzip -f will only add to the output file if the input data is newer than what is already in the output file. All files that do not exist in the output file will also be added. Then you may unzip the result to a folder and then zip it up again to obtain an efficiently packed result file. You can even do this automatically after the FOR loop at the end of the batch file."