问题
I'm using command line 7zip to zip up the contents of a folder (in Windows) thus:
7za a myzip.zip * -tzip -r
I've discovered that running exactly the same command line twice will produce two different ZIP files - they've got the same size but if you run a binary compare (ie fc /b file1.zip file2.zip) they are different. To complicate matters it seems that if you make the two zips in rapid succession then they are the same. But if you do them on different days or separated by a few hours they are not.
I presume that there's a date/time stamp in the ZIP file somewhere but I can't find anything on the 7zip site to confirm that.
Assuming I'm right does anyone know how to suppress the date/time? Or is something else causing the binaries to be different?
回答1:
7-zip has the switch -m
with parameter tc
which has value on
by default if not specified on command line.
With -mtc=on
all 3 dates of a file stored on an NTFS partition are stored in the archive:
- the last modification time,
- the creation time, and also
- the last access time.
See in help of 7-zip the page with title -m (Set compression Method) switch.
The last access time of the files is most likely responsible for the differences between the archive files.
You have to append -mtc=off
to avoid storage of the NTFS timestamps in archive file.
来源:https://stackoverflow.com/questions/27136783/7zip-produces-different-output-from-identical-input