On a Mac, When I zip and unzip files using finder or using zip/ditto from command line, I lose the creation date of the files/folders and the creation date is automatically set same as the modification date. How can I preserve the creation date?

  1. Get file creation date.

    • (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error
  2. zip

  3. set file creation date.

Use tar with the p(reserve) option:

 tar -x -p -v -j -f arhive.tbz
  • Is tar on OSX different from GNU tar? For the latter the p option is --preserve-permissions.
    – mpy
    Mar 17 '13 at 12:07
  • -P preserves absolute path names and has nothing to do with time information. tar always stores owner and permission information by default, and restores it again.
    – Daniel Beck
    Mar 17 '13 at 19:29
  • 1
    -p tries to preserves permissions (i.e. file mode, ACLs) when restoring. It's only applicable to -x (extraction). Plain old tar cf and tar xf preserve modification times already, no additional args needed. AFAIK creation date cannot be influenced.
    – Daniel Beck
    Mar 17 '13 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy