Changing file creation date - can't go newer

Discussion in 'macOS' started by Spikeywan, Jan 13, 2013.

  1. Spikeywan macrumors 6502

    Dec 11, 2012
    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?


    Even the app described here won't make the date later:
  2. McGiord macrumors 601


    Oct 5, 2003
    Dark Castle
    What about changing the computer date to the date you want, and then doing what you are doing?
  3. balamw Moderator


    Staff Member

    Aug 16, 2005
    New England
    Have you tried using something like exiftool to automate the process?

    touch [I]filename[/I]
    not make the date today?

  4. Spikeywan thread starter macrumors 6502

    Dec 11, 2012
    Nope. 'touch filename', 'touch -t filename' and 'touch -t 20120113 filename' change the Modified and Last Opened dates, but not the Created date.
  5. Spikeywan thread starter macrumors 6502

    Dec 11, 2012
    I've found a way...

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

    Is there a better way?
  6. switon, Jan 14, 2013
    Last edited: Jan 14, 2013

    switon macrumors 6502a

    Sep 10, 2012
    RE: creation, modification, access dates...

    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.


Share This Page