Change a File’s Last Modified and Creation Dates on Mac OS X and Linux

Date Format Key:

  • YYYY?—?The year (the first two digits/century can be omitted).
  • MM?—?The month of the year, from 1 to 12.
  • DD?—?The day of the month, from 1 to 31.
  • hh?—?The hour of the day, from 0 to 23.
  • mm?—?The minute of the hour, from 0 to 59.

How to change the “date modified” attribute of a file in Mac OS?

1. Open up the Terminal application (/Applications/Utilities/ or if you prefer use iTerm.
2. Type this into Terminal (without hitting enter/return) replacing YYYYMMDDhhmm with the desired date information:

touch -mtYYYYMMDDhhmm

3. Open a Finder window and locate the file you wish to modify and drag and drop it into the Terminal window. Here’s an example of what should be typed into the Terminal at this point:

touch -mt200801120000 /Volumes/Mac\ HD/Pictures/somefile.jpg

200801120000 in the example above represent “January 12, 2008 12:00 AM” or my 21st birthday. Make sure to change 200801120000 to the date you want and to replace /Volumes/Mac\ HD/Pictures/somefile.jpg with the proper path to the file you wish to alter the date for.

4. If all is in order press the return key.

How to change the “date modified” attribute recursively?

find ./folder/ -type f -exec touch -mt 07011200 {} \;

How to change creation date too?

Just remove m argument:

touch -t200801120000

What’s about Linux?

It’s the same but with additional space:


touch -mt YYYYMMDDhhmm

and recursive one:

find ./folder/ -type f -exec touch -mt 07011200 {} \;

2 thoughts on “Change a File’s Last Modified and Creation Dates on Mac OS X and Linux”

  1. I was just seeking this info for some time. After six hours of continuous Googleing, at last I got it in your web site. I wonder what is the lack of Google strategy that don’t rank this kind of informative websites in top of the list. Generally the top sites are full of garbage. gedegfedbege

Leave a Reply

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