Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Spikeywan

macrumors 6502
Original poster
Dec 11, 2012
252
0
I have some JPGs that I need to change the creation date of, to reflect the day that they were taken.

If I use touch, I can set the creation date earlier, but not later.

I'm using this command: touch -t 201209071000 pic.jpg

I changed a file's date to 2010 by mistake, and I can't get it back to 2012. But, I can change the date to 2009.

What am I doing wrong?

Thanks.

Even the app described here won't make the date later: http://hints.macworld.com/article.php?story=20060703160750583&query=change%2Bcreation%2Bdate
 
Nope. 'touch filename', 'touch -t filename' and 'touch -t 20120113 filename' change the Modified and Last Opened dates, but not the Created date.
 
I've found a way...

cat oldfile > newfile
rm oldfile
mv newfile oldfile
touch -t 201209071000 newfile

Is there a better way?
 
RE: creation, modification, access dates...

I've found a way...

cat oldfile > newfile
rm oldfile
mv newfile oldfile
touch -t 201209071000 newfile

Is there a better way?

Hi Spikeywan,

The utility "touch" and the system call "utimes" are designed to set the modification and access times, not the creation time of a file. But since the modification and access times cannot be earlier than when a file was created (without violating causality), by resetting the modification time to a time earlier than the creation date forces the creation date also to the earlier time.

In other words, you have discovered a way to reset the "creation" date on a file to a later date -- by copying to a newly created file and then resetting the modification date to an earlier date. Of course, this is not actually reseting the creation date on a file, rather it is resetting the creation date on a new and different file, but one that has the same contents as the original file.

The "stat" and "lstat" utilities can be used to show you the various times associated with a file.

Regards,
Switon
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.