How to change the creation date of a file in OS X

If you need to change the “date modified” and “date created” attributes of some file. In OS X can be easily done using the Unix console.

Change date created

For changing the creation date just use use the command touch -t followed by the date and the path of the file. The date has the following format [[CC]YY]MMDDhhmm[.SS]]:

  • CC The first two digits of the year (the century).
  • YY The second two digits of the year.
  • MM The month of the year, from 01 to 12.
  • DD the day of the month, from 01 to 31.
  • hh The hour of the day, from 00 to 23.
  • mm The minute of the hour, from 00 to 59

For example for changing the creation date of the file test.doc to 16:15 11st of December 2012:

touch -t 201212211615 /path_to_the_file/test.doc

Note that this will change both “date modified” and “date created” attributes.

Change date modified

Changing the “date modified” attribute is similar to the previous step, but just using touch -mt instead:

touch -mt 201212211111 /path_to_the_file/test.doc

Change date to all files

For changing the creation/modification date to all files inside a folder just add /* to the folder path:

touch -t 201212211111 /path_to_the_folder/*

Other way to get this done using find:

find ./path_to_the_folder/ -type f -exec touch -mt 12011200 {} \;

Comments 6

  1. Hi. I tried the ‘touch -t’ to change both Created & Modified date, but it only changed the Modified date – not the Created date.
    So, then I tried the ‘touch -mt’ and it changed the Modified date, like you said, which is fine. But, I need the Created date to change and the instructions didn’t work for that…maybe something has changed since 2015?…wish I knew.

    Thanks for posting instructions, though.

  2. I am very, very surprised that a Mac allows this kind of a modification. I thought one of the main advantages of closed source OS was its integrity and security. Being able to alter the date of a file seems to be a rather significant loophole in my opinion.

    In any case, thanks for the tip. I needed this little hack for a simple tweak on my Mac but I can’t help but wonder how this hack can be misused.

    1. I get your point about Mac allowing this kind of modification.

      Like, who would want to modify the Created Date of a file, right?

      Answer: anyone who has taken a photo with a camera that reset its own calendar.

      My phone had decided that it was now midlnight on the first of January, 2014 — most definitely not the date at which I took the photo, which affects all of my searching and cataloguing.

      Wouldn’t it be wonderful if devices that automatically time-stamp files also kept account of updates to their own internal clock and, quite reasonably, volunteer to update the metadata or file info for such obvious mistakes?

    2. To answer your concern, there are several important things to remember. Mac, its media assets and all user content – belongs to the USER, and no one else. You do NOT limit functionality for any reason. Functionality comes BEFORE security.

      Here’s my example: I just brought image files from a digital camera whose battery was drained, and so the time-stamp on all image files was 1/1/1970 00:00:00. Should I not be able to fix the erroneous creation dates?

      Next. Having functionality does not, in general, mean less security, and there is no “loop hole” here. The information about the user action (changing creation date) does NOT go in the dark. First – MacOS file systems (HFS+ and APFS) are Journaled and maintain versioning of everything – so if you care to KNOW that the user changed creation date of a file – you can.

      I’d like to know why changing file time-stamps seems to be a “hack” for you.

  3. Hi, Thanks. I have a question. Regarding the arguments of touch -t -mt —

    The date format is [[CC]YY]MMDDhhmm[.SS]]

    What I make of it is that century is optional, year is optional (probably they default to the current year) and that seconds of the time are optional. However: you have extra ending bracket at the end — and the Month, Day, Hour and Minute – seem to be non-optional.

    A very frequent occurrence – I receive set of Image files from a camera whose date was never set (01/01/1970) but the Time is more or less OK — how can I change ONLY THE DATE without affecting the TIME of the creation/modification date? Here it seems impossible, unless you miss some brackets in your description – and in any way you didn’t write what would skipped-optional-options default to.

Leave a Reply to Karla Cancel reply

Your email address will not be published. Required fields are marked *