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.zipI saw this post in 2011, and wonder if there is a solution?
Can we preserve the timestamps of files when extracting .zip archive?
zip
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?UpdateSub-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.ljames@ubunzeus:~/Downloads/open/del/2$ unzip ~/Downloads/Ortho4XP.zipljames@ubunzeus:~/Downloads/open/del/2$ ls -ltatotal 888drwxrwxr-x 17 ljames ljames   4096 Aug  7 17:11 .drwxrwxr-x  3 ljames ljames   4096 Aug  7 17:11 __MACOSXdrwxrwxr-x  2 ljames ljames   4096 Aug  7 17:11 Licencedrwxrwxr-x  2 ljames ljames   4096 Aug  7 17:11 Archivesdrwxrwxr-x 12 ljames ljames   4096 Aug  7 17:11 Patchesdrwxrwxr-x  3 ljames ljames   4096 Aug  7 17:11 Previewsdrwxrwxr-x  3 ljames ljames   4096 Aug  7 17:11 Utilsdrwxrwxr-x  5 ljames ljames   4096 Aug  7 17:11 Installdrwxrwxr-x  3 ljames ljames   4096 Aug  7 17:11 Manualdrwxrwxr-x  5 ljames ljames   4096 Aug  7 17:11 bindrwxrwxr-x  4 ljames ljames   4096 Aug  7 17:11 ..-rwxr--r--  1 ljames ljames 389049 Feb 24 19:02 Ortho4XP_devel.py-rwxr--r--  1 ljames ljames 388606 Jan 12  2017 Ortho4XP_v120b.py-rwxr--r--  1 ljames ljames  36037 Jan 12  2017 Carnet_d_adresses.py-rwxr--r--  1 ljames ljames   6716 Sep 12  2016 Ortho4XP.cfgdrwxr--r--  2 ljames ljames   4096 Aug 31  2016 OSM_datadrwxr--r--  2 ljames ljames   4096 Aug 31  2016 Tiles-rwxr--r--  1 ljames ljames  13332 Jul 10  2016 README.install_NOT_UP_TO_DATEdrwxr--r--  2 ljames ljames   4096 Jul 21  2015 Elevation_datadrwxr--r--  2 ljames ljames   4096 Jul 21  2015 Masksdrwxr--r--  2 ljames ljames   4096 Jul 21  2015 Orthophotosdrwxr--r--  2 ljames ljames   4096 Jul 21  2015 tmpljames@ubunzeus:~/Downloads/open/del/2$Update #2I'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.