I want to unzip a .zip archive, and preserve the timestamps of the files extracted.
But this command doesn't preserve the timestamps:
unzip my.zip
I saw this post in 2011, and wonder if there is a solution?
zip
I want to unzip a .zip archive, and preserve the timestamps of the files extracted.
But this command doesn't preserve the timestamps:
unzip my.zip
I saw this post in 2011, and wonder if there is a solution?
Best Answer
Using unzip without and arguments will, by default, extract files and preserve the directory structure and time stamp.
You can use the -l argument to get a listing which will show you the time stamp of the files. The extracted content will match what you see from the listing.
If you see something different with the zip file you're trying to open, can you show us the output of the "-l" listing as well as an
ls -l
listing of the extracted directory?Update
Sub-folders retain the timestamp of the zip archive. However, if the folder is on the top level, it will lose the original timestamp and assume the timestamp of when it's extracted.
This is an example. The Ortho4XP.zip file is a zip file that contains over 300 files and subdirectories. Today is August 7, 2017. As you can see from the output the top level directories will assume the date that the archive is unzipped. However, as you can see from the output the other files and sub-directories retain the timestamp of when the files were zipped.
Update #2
I'm still studying to figure out what is the difference between the folders that are not retaining the archive timestamp and the ones that are. I'll update the answer to be more definitive soon. It may depend on the option used in creating the zip file.