34

I have a directory that I have been storing a ton of files in. Among the 10ish types of files there are also .zips of other directories.

In my personal experience I vaguely remember issues when trying to zip zips (ha zip zips).

Will compressing an already compressed file cause immediate problems, or potentially problems later on when I attempt to uncompress it?

I read Can zipping a file break it?, but it does not really address the zipping of zips. I did notice that corruption can cause zips to break. Would zipping zips potentially corrupt files?

0

5 Answers 5

50

Zipping zips is fine. If there is a problem, that would be a bug in the compression software :).

You will probably not get any further compression for those files though unless you're using a higher level of compression.

3
  • 2
    Well, there are different levels of compression. If you've just used the "package" method on the zips in the folder you're zipping, which doesn't compress anything, you may get compression on the files. If you used maximal compression on the zips to be zipped you probably won't get any more compression. Then again, if the maximally zipped zips you're zipping share compressable content with other files in the folder getting zipped, you'll get compression. So that "obviously" bit probably isn't exactly accurate. Everything else is though. Commented Mar 8, 2012 at 18:16
  • 14
    the zip format compresses each file individually, so zipping a zip file actually can save some space; particularly the metadata is effectively uncompressed, and will be compressed in the zipped-zip. Probably the very best compression possible is by using no compression to collect the individual files into a single archive and then using maximum compression to reduce the single-archive size. This is basically the same idea with the .tar.gz format. Commented Mar 8, 2012 at 21:24
  • 1
    Zipping a zip can gain you more space even if the compression is the same.
    – m4tt1mus
    Commented Mar 9, 2012 at 1:02
14

Zipping a zip might confuse AV software. There are zips, which contain themselves as a new zip of themselves, which leads to an endless recursion if your AV software tries to inspect a zip in a zip, and to avoid such an recursion, the AV software might make a false alarm.

Tools which search in zips like zgrep will not inspect zips in zips. But if you are aware of it, this might not be such a problem.

The compression result can suffer. Think of 2 zipfiles:

a.zip
- a.txt 
- b.txt 

b.zip
- b.txt

a.zip and b.zip can be very different and hard to compress further. If zipping

combined.zip
-a/a.txt
-a/b.txt
-b/b.txt

both b.txt-files can be compressed very good.

So deflating internal zips before compressing the whole thing might lead to smaller results, but more importantly, it leads to better usable results.

1
  • 1
    +1 for mentioning additional possible problems, apart from data corruption
    – sleske
    Commented Mar 9, 2012 at 8:17
6

You can do that, you shouldn't see any problem but compressing a compressed folder, you won't gain a lot of compression. That's it...

0

I recently had a project that dealt with tar files. The resulting file contains all of the files but they are not compressed. In my opion tar files are a excelant way to archive zip files.

-2

.tar files are not compressed files. .tar files are for wrapping multiple files into one. .gz files can only zip one file. So to make a multiple-file .gz compressed file, you make a .tar file and turn that into a .gz file. But there are no merits to compressing a pre-compressed file. So it makes no sense to make (for example) a .tar.gz.gz or a .zip with only .zips in it.

1
  • 1
    The original question doesn't say anything about .tar files, and .tar files aren't "for wrapping multiple files into one .gz file". And while compressing a compressed file won't give you more compression, it may be useful to include compressed files in an archive, so you only have one file to move around instead of multiple.
    – blm
    Commented Jan 14, 2016 at 18:25

You must log in to answer this question.

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