How to zip and unzip files on mac OS without losing creation date/time

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? Does AppleScript do it?

So far, I haven’t found any solution.

Please help, if you can. Thanks.

Have you tried using the --rsrc --extattr options?

man ditto 


I think you can use the zip utility ( man zip ) but I think you’ll have to remove the resource fork manually afterwards.

By the way, here is the way to create a cross platform archieve with zip, similar to the ditto ”norsrc command.

do shell script "zip -dr " & quoted form of pxFn & " __MACOSX/\\* >/dev/null ; unzip -l " & quoted form of pxFn & " |grep \".DS_Store\" | tr -s \" \" |cut -d \" \" -f 5-20 |zip -d " & quoted form of pxFn & " -@ >/dev/null ||echo >/dev/null"

Yes, I had tried that. Ditto doesn’t preserve the creation date. At-least I haven’t figured out how to use ditto to preserve it.

Hi, I downloaded your code and tried to run it on my computer.
I am assuming pxFn above is a variable holding the path to the file/folder I want to zip. Right?

I ran the code, but not sure what it did, since didn’t see any zip file created anywhere.

I manually ran zip and unzip from command line, but creation date was not preserved, it was set same as modification date. I am looking at the finder for these dates.


The last line was for removing the resourcefork from an already created archieve.

I have looked at 7-zip which according to my tests preserves the file creation dates. I don’t know about the compatibility with ditto or zip though, so I have no idea if 7-zip fills your quota in other ways than preserving the file creation date when compressing, and extracting archieves. But it works for me.

I compressed the current directory with this commandline:

7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z .

and extracted with this: in a subdirectory, and at least the file creation dates are the same!

7z e ../archive.7z

But the modification date, isn’t preserved.

You may find this interesting

I haven’t but it may also be interesting to look into gzip (man gzip) I think there is a great likelihood that gzip may hack it, but I may be wrong. The advantage of gzip, is that it is more widespread than 7-zip if you first has to take such measures. According to this manpage it can! :slight_smile:

I tried gzip -N filename, but that worked same as zip and ditto. Meaning didn’t preserve the creation date/time.

7z is not included by default on MACOS and seems you said that it didn’t save modification date when uncompressed?
I am looking for a solution that preserves both creation and modification dates. So far all solutions on MAC preserve modification dates but not creation dates.


I think you cant get 7-zip as a binary package from SoftPedia or similiar. Maybe Macports, I am not sure how I got it myself, whether I downloaded, or built it.

7-zip does preserve the creation date. On the link I referred to, they purport in the last post that you can preserve the modification date as well.

There is another option, if you manage to get it all stored in the archieve, you can always use that information afterwards together with a utility like touch or SetFile to “adjust” creation and modification dates.


It beats me, that maybe another path to a solution, is to look into cpio, or rsync, in combination with a disk image that you then zip? Just ideas.