Cannot change file creation date

I have files with no creation date or creation date 1969, etc (came from bad settings in camera).

Since I knew the date, I was able to easily fix it via touch:

touch -t 20090110 IMG_1023.JPG


This used to set creation, modification, and access time to 20090111, in Snow Leopard. However, I can no longer do this in Lion. It does set modification and access, but creation date is still screwed up.


I know there are apps that claim can do this, but I would rather solve the problem within the OS.


Thanks in advance

macbook pro 2007, Mac OS X (10.7.2), iPhone 3GS, 4, iPad2, latest iOS5

Posted on Feb 12, 2012 10:32 AM

Reply
15 replies

Feb 12, 2012 11:44 AM in response to unixnerd09

Touch cannot change the creation date, only the modification and access times. By using cp, you are 'creating' a new file. You can see that touch does not change the creation date with ls -lU


The file's creation date was probably changed when you copied the files from your camera, but the Metadata most likey retained the bad date (you can verify with the mdls command)

Feb 12, 2012 3:20 PM in response to Tony T1

Thanks for the "ls -lU" tip, very useful.


Yes, I am creating a new file. My point is that "touch -t" does change the creation date of the new file, but not of the old file.


Original file and copy:

493607 Feb 12 18:09 IMG_0556-copy.JPG

493607 Dec 31 1969 IMG_0556.JPG


Try to change date:

touch -t 200901110000 IMG_0556*


New file has new creation date, old file still the same

493607 Jan 11 2009 IMG_0556-copy.JPG

493607 Dec 31 1969 IMG_0556.JPG


Another tets, similar resut:

touch -t 200501110000 IMG_0556*


493607 Jan 11 2005 IMG_0556-copy.JPG

493607 Dec 31 1969 IMG_0556.JPG


The difference is that original file has a before-beginning-of-time creation date Dec 31 1969 ("beginning of time" being of course Jan 1st 1970).

Feb 12, 2012 3:36 PM in response to Tony T1

but I do see some trace of the old date even in the new file, so you have a point.

But the finder shows 2005, just like "ls -lU"


kMDItemDateAdded = 2012-02-12 23:09:36 +0000
kMDItemDisplayName = "IMG_0556-copy.JPG"
kMDItemFSContentChangeDate = 2005-01-11 05:00:00 +0000
kMDItemFSCreationDate = 2005-01-11 05:00:00 +0000
kMDItemContentCreationDate = 1970-01-01 00:00:00 +0000

kMDItemContentModificationDate = 2005-01-11 05:00:00 +0000

Feb 12, 2012 3:43 PM in response to Tony T1

Sorry. the new file is actually clean. No trace of year 1969 or 1970.


kMDItemAcquisitionMake = "Canon"
kMDItemAcquisitionModel = "Canon PowerShot SD770 IS"
kMDItemAperture = 2.96875
kMDItemBitsPerSample = 32
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2005-01-11 05:00:00 +0000

kMDItemContentModificationDate = 2005-01-11 05:00:00 +0000

kMDItemContentType = "public.jpeg"
kMDItemContentTypeTree = (
"public.jpeg",
"public.image",
"public.data",
"public.item",
"public.content"

)

kMDItemDateAdded = 2012-02-12 23:09:36 +0000
kMDItemDisplayName = "IMG_0556-copy.JPG"
kMDItemEXIFVersion = "2.2"
kMDItemExposureMode = 0
kMDItemExposureTimeSeconds = 0.01666667
kMDItemFlashOnOff = 1
kMDItemFNumber = 2.799999952316284
kMDItemFocalLength = 6.2
kMDItemFSContentChangeDate = 2005-01-11 05:00:00 +0000
kMDItemFSCreationDate = 2005-01-11 05:00:00 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "IMG_0556-copy.JPG"
kMDItemFSNodeCount = 493607
kMDItemFSOwnerGroupID = 99
kMDItemFSOwnerUserID = 99
kMDItemFSSize = 493607
kMDItemFSTypeCode = ""
kMDItemHasAlphaChannel = 0
kMDItemISOSpeed = 250
kMDItemKind = "JPEG image"
kMDItemLogicalSize = 493607
kMDItemOrientation = 0
kMDItemPhysicalSize = 495616
kMDItemPixelCount = 1920000
kMDItemPixelHeight = 1200
kMDItemPixelWidth = 1600
kMDItemProfileName = "sRGB IEC61966-2.1"
kMDItemRedEyeOnOff = 1
kMDItemResolutionHeightDPI = 180
kMDItemResolutionWidthDPI = 180
kMDItemWhiteBalance = 0

Feb 12, 2012 5:07 PM in response to unixnerd09

unixnerd09 wrote:


Thanks for the "ls -lU" tip, very useful.


Yes, I am creating a new file. My point is that "touch -t" does change the creation date of the new file, but not of the old file.


Yes, I now recall now that you can change the creation date if -t is before the mod date


Create new file:

touch test.txt

ls -lU test.txt

-rw-r--r-- 1 Tony staff - 0B Feb 12 19:52 test.txt

Wait a few minutes and...

touch test.txt

ls -l test.txt

-rw-r--r-- 1 Tony staff - 0B Feb 12 19:54 test.txt

ls -lU test.txt

-rw-r--r-- 1 Tony staff - 0B Feb 12 19:52 test.txt

And if I...

touch -t 200901100000 test.txt

ls -l test.txt

-rw-r--r-- 1 Tony staff - 0B Jan 10 2009 test.txt

ls -lU test.txt

-rw-r--r-- 1 Tony staff - 0B Jan 10 2009 test.txt

But now...

touch -t 201002100000 test.txt

ls -l test.txt

-rw-r--r-- 1 Tony staff - 0B Feb 10 2010 test.txt

ls -lU test.txt

-rw-r--r-- 1 Tony staff - 0B Jan 10 2009 test.txt

Sep 5, 2013 6:48 PM in response to Ashmac21

The HFS creation date is not mapped cleanly onto UNIX file system semantics. Plus, becaues of the way many applications overwrite files, creation date and modification date are often identical. You may have to hunt around for some text file you have edited with vi to see the difference.


I'm sure there is some command-line OS X tool that will let you set the creation date. I don't know what it might be. You may have to use Apple script or even write a Cocoa program to access the HFS metadata if you want to actually set the creation date.

Sep 5, 2013 6:59 PM in response to Ashmac21

Sorry, maybe I was not clear enough.

What is your file creation date? If it is *nonsensical* or *before* Jan 1, 1970, then you have to do (1) in my last post before doing "touch". The "touch" command will not change a nonsensical creation date, at least this was my experience one or two Mac OSs ago (Lion or Snow Leopard, I do not remeber).


Now, if your creation date makes sense (real date, *after* Jan 1, 1970) and you were not able to change it as NBAR advised, I do not know what to do, sorry.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Cannot change file creation date

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.