Changing file creation date - can't go newer

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

  1. Spikeywan macrumors 6502

    Joined:
    Dec 11, 2012
    #1
    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
     
  2. McGiord macrumors 601

    McGiord

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

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #3
    Have you tried using something like exiftool to automate the process?

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

    B
     
  4. Spikeywan thread starter macrumors 6502

    Joined:
    Dec 11, 2012
    #4
    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

    Joined:
    Dec 11, 2012
    #5
    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

    Joined:
    Sep 10, 2012
    #6
    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.

    Regards,
    Switon
     

Share This Page