Menu

ZIP archive folder date preservation

Help
Jimbob
2011-01-14
2023-08-21
  • Jimbob

    Jimbob - 2011-01-14

    I've been using 7zip 9.20, command line version. I have noticed that when extracting from a ZIP archive, the folder dates are - for some folders - set to the date of extraction, not the date the folder was originally created, although viewing the archive in 7zip file manager does show that the original folder creation date is recorded. The ZIP archive was created using 7zip 9.20, command line version. Note that this is not a problem when using 7zip to create and extract a 7Z archive - original folder dates are correctly preserved upon extraction for all folders.

    An aside, according to 7-zip.chm, -mtc=on is the default for ZIP file creation, but -mtc=off is the default for 7Z. Why the difference? Also, the descriptions differ in 7-zip.chm:

    For Zip, "Stores NTFS timestamps for files: Modification time, Creation time, Last access time."
    For 7z, "Stores file creation timestamps."

    Is there actually a difference between what the two archive types store?

     
  • Igor Pavlov

    Igor Pavlov - 2011-01-15

    Zip format stores modified time (FAT / local time). But we need UTC NTFS timestamp. When you enable UTC NTFS timestamp, zip writes all timestamps (accesses, modified, created).
    7z format can store any of timestamps. Since only modified is most important, other are disabled.

     
  • Jimbob

    Jimbob - 2011-01-15

    Hi,

    Thanks for the swift reply and the explanation. Any idea why extracting from ZIP sometimes results in the extraction date being applied to the folder(s)?

     
    • Casteele M.

      Casteele M. - 2022-04-23

      Just a guess... By default, Windows' Explorer displays the last modified time stamp. But if you change it to "creation" or "access" time stamps, it may display unexpected results -- 7-zip may be correctly setting them, but then your virus scanner, for example, might run behind 7-zip and access the file to scan it, thus changing the access time stamp. Many things can do this, and you should only rely on last modified time stamps. (Un*x, for example, does not have a creation time stamp at all -- the "ctime" from the system "stat()" call is "iNode [C]hange time" not "[C]reation time" like it is on FAT/NTFS. Newer Un*x distro's have added a "Birth time", however.)

      What I suggest is that if time stamps are critical to your needs, if at all possible, maintain a separate auxiliary file/database to keep track of it. Of course, this will not work smoothly for many tools which operate on the file system provided time stamps (such as rsync, etc.).

       
  • Jose

    Jose - 2011-05-10

    Hi,

    I'm looking for help within this same subject, so I felt I didn't need to open a new discussion but just adding to this one.

    I'm using 7z to extract zip files (where I don't know who/what zipped them). I found that 7z does not preserve the right/original timestamps (for Date Created and Date Last Accessed) when unzipping some files (only the Date Modified is preserved).

    I run some tests, zipping files with windows (via compressed folders), winzip and 7z.:
    - If I use 7z or winzip to zip, it will keep the original timestamps when unzipping the files.
    - If I use compressed folders, 7z will not include the original timestamps when unzipping.
    - In every case, WinZip includes the right original timestamp in the three properties "Date Created", "Date Last Accessed" and "Date Modified".

    Is there any way to make 7z to correctly preserve the date information/timestamp when extracting ZIP files? (just like WinZip does).

    Thanks.
    - Jose -

     
  • Igor Pavlov

    Igor Pavlov - 2011-05-11

    "compressed folders" application doesn't include Created and Last Accessed timestamps to archive.
    So 7-Zip can't restore them. WinZip also can't do it. Check it again.

     
  • Jose

    Jose - 2011-05-11

    Hi Ipavlov,

    I'm afraid my test results don't agree with you. I just performed an additional quick test to verify it:

    OS: Win 7
    7z version 9.20
    WinZip 15.5

    - I compressed two files, a MS word file and a text file via "Send to Compressed (Zip) folders" context menu.
    - I unzipped them via 7z and it did not preserve the Date Created and Date Accessed properties.
    - I unzipped them with WinZip and it did preserve all the properties in both files.

    Thanks.
    - Jose -

     
  • Jose

    Jose - 2011-05-11

    Ipavlov,

    I think I found out what happened… Winzip is cheating :-)
    For all my previous tests, the files had the same Date Created, Date Accessed  and Date Modified. So when I unzipped them, it was clear that Date Created and Date Accessed were not preserved since they were different than the original date and also than Date Modified. And that's where I made the wrong assumption.

    Doing more tests I realized that what Winzip  is doing (in the case of zip files by Compressed Folders) is just copying the Date Modified into Date Created and Date Accessed, as opposed as 7z that is inserting the current date/time. This only became obvious when I changed the Date Modified so it was different that Date Created and Date Accessed.

    So yes, you were right in that Compressed Folders don't store those timestamps, I got tricked by Winzip :-)

    Thanks!
    - Jose -

     
  • Arcie Dy

    Arcie Dy - 2011-07-28

    My problem re date is different:  I need to know if a certain archive contains the latest file(s).  This is achieved by WinZip with the parameter -o  (lower case letter o).  This parameter changes the Zip file's file date to the same as the newest file in the Zip file.

    If for example ABC.zip contains two files: A1.txt dated 2011 July 1 and A2.txt dated 2011 July 4 and I zipped them on 2011 July 25 using the -o option, then ABC.zip will have a file date of  2011 July 4, not 2011 July 25.

    Will 7-zip soon have this capability?

     
  • g4j

    g4j - 2012-08-10

    I need to echo what arciedy said. I really need 7z to have an option where the date of the archive will be set the the most recent date of the file(s) it contains. 7z is a great application, but the lack of more robust date control is problematic for my automated processes.

     
  • Karol Moran

    Karol Moran - 2012-12-06

    Add:
    ta tc
    to parameters when creating archive and file dates are preserved.

     
    • Michael Uray

      Michael Uray - 2018-10-31

      These parameter work fine for me in the GUI.
      How can I add them to my command line application?

      I have tried
      7zG.exe a -t7z -ta -tc "archive.7z" "folder1"
      but this did not work, so I guess there is another way set these parameters.

       
      • Michael Uray

        Michael Uray - 2018-10-31

        Nevermind, I found it in the meanwhile.
        The switch are
        -mta -mtc

         
  • WAGNER CASTILHO FERREIRA

    Good afternoon,
    can you help?
    I want to make the zip but keeping the timestamp of the file.

    C:\Program Files\7-Zip\7zG.exe" a -t7z -mtc -mta "$($FilesCOMPdel.fullname).zip" "$FilesCOMPdel"

     
  • WAGNER CASTILHO FERREIRA

    correct

    C:\Program Files\7-Zip\7zG.exe" a -t7z -mta -mtc "$($FilesCOMPdel.fullname).zip" "$FilesCOMPdel

     
  • Casteele M.

    Casteele M. - 2022-04-23

    Given how often I see people with time stamping concerns/issues...

    7-zip itself is an archive management and format application; It is not a file management application, or a backup management application. While there are options to assist with these things, it can only assist to a certain point. After that point, you will need to use some kind of application dedicated to the task.

    There are dozens of file managers and backup managers on the internet -- many of them are free and available on SourceForge or GitHub. There are also many different version control applications, and SF and GH are actually built on top of such concepts.

    You can use the handle of a screwdriver to pound a nail in, but it is generally more effective to use a hammer. Use the right tool/application designed for the task you need, instead of trying to force the wrong tool to do the thing you want.

     
  • An mac

    An mac - 2022-11-06

    Has anyone tried zipping folders (either through winzip, winrar and created .7z, .rar, .tar, .wim or other archive formats) with android and then extracted to PC and preserved date created, date modified and date accessed of that folder?

     

    Last edit: An mac 2022-11-06
    • Tiago

      Tiago - 2023-08-21

      Using the Samsung Files app on my Galaxy, I was able to create an archive.zip with some pictures. After copying to my PC and opening it, I was able to check that the "Date Modified" attribute is still kept. However, the "Created" and "Accessed" attributes are empty.

       
      • An mac

        An mac - 2023-08-21

        I have the same problem, so it seems that date created and date accessed timestamps are not saved from android. Which android version do you have and which device?

         
  • An mac

    An mac - 2022-12-27

    Any updates on this issue?

     

Log in to post a comment.