Rewrite last modified date when unzipping archive

datefilesosxzip

Is there a way to rewrite the last modified date of all the files inside a .zip file to the date of extraction?

Basically, whenever someone unzips the archive, the last modified date of all files is changed to the date of the zip extraction?

Best Answer

With libarchive bsdtar (supports all sorts of archive formats, including pkzip's), use the m flag:

bsdtar xmf file.zip

From the manual:

-m, --modification-time
(x mode only) Do not extract modification time. By default, the modification time is set to the time stored in the archive.

Note that the m flag is not specific to bsdtar, it was already there in the first implementation of tar in Unix V7 in 1979. What is specific to bsdtar is the support for archive formats other than tar.

With unzip, see the -DD option.

Related Question