how-to

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.

Go to answer for Mac OS High Sierra

Go to answer for Mac OS El Capitan and older

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

Unfortunately, new versions of Mac OS have different version of touch command, try these steps:

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

touch -m -t YYYYMMDDhhmm

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 -m -t 200801120000 /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 -m -t 200801120000 {} \;

How to change creation date too?

Just remove m argument:

touch -t 200801120000

 

Alternatively, you can install xcode command line tools, and follow all steps:

xcode-select --install

Then you can use it’s command to change creation date, date syntax is MM/DD/YYYY HH:MM:SS (where HH is hours in 24h format):

setfile -d "02/28/2016 13:21:59" FILENAME.PNG

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

1. Open up the Terminal application (/Applications/Utilities/Terminal.app) 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 -mt200801120000 {} \;

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 {} \;

30 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

    1. Sorry for late reply, but these commands can only change file system created and modified date. If you want to change video metadata – you need to use some video editor.

  2. Had a whole month of pics on my Mac with the wrong year originally set on camera. Been stumbling through confusing websites and youtubes before I found your clear explanation.

    Thanks!

  3. This does not work anymore. The terminal says “out of range or illegal time specification”. Any idea how to write the date nowadays 2018?

    1. Looks like there was some problem with date format you’ve specified.

      Could you give me the full command, which you wrote?

  4. im trying to change a file to “Date Created: 12. December 2017”

    I made this:
    touch -t201712120000/Users/espenostendorf/Desktop/Das\ Business\ Simulation\ Game\ ist\ eine\ Form\ des\ aktiven\ Lernens\ unter\ experimenteller\ Bedingungen.docx
    touch: out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]

  5. Hi there,
    I am trying to change only the date modified but when I use touch -mt… it changes both the date created and date modified. Am I doing something wrong?
    Thanks

  6. Hi
    thanks for the clear explanations, I had the same problem (forget the space after the argument).
    however, after correction of the command, it works but it changes only the “date modified”, not the “date created”.
    here is my command:
    MacBook-Pro-de-Guillaume:~ Guillaume$ touch -t201807241100.00 /Users/Guillaume/Movies/2018-vacances\ été/GOPR0867.MP4
    I work on Mac OS High Sierra.
    I copied a file twice and tried with “touch – t” and “touch – mt” to see if I get something different, but in both cases, only the “date modified” is changed.
    Could you advise me how to change the creation date too?

    1. Please try to change date to something in future first, and after it change to needed one. Looks like new version of touch in Mac OS doesn’t work as expected.

        1. Thank you so much for giving the link to that website. Usually I am hesitant to trust third-party apps, but this one was invaluable for me! You have definitely helped me more than you know.

  7. Hi there,

    I want to change the creation date to 1 month newer. And keep the other dates the same.

    I’m on mac 10.11.6

    Using terminal

    I’m inputting

    touch -t201612131507/Users/myname/Desktop/time/131.jpg

    I get this message back

    out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]

    Any ideas?

    Thanks

    1. Hello James,

      you need to add a space between touch -t201612131507 and /Users/myname/Desktop/time/131.jpg, so your command should be: touch -t201612131507 /Users/myname/Desktop/time/131.jpg

  8. Hi there, I am trying to change a word doc creation date, but when I do what is asked it only changes the modified date, not the creation date. I tried just t, tm and it only changes the modified date.. any suggestions would be great, thanks!

  9. Hello, could you please help me as well. Don’t know why is not working :
    touch -t 201712120000/Users/anytsujj/Desktop/33657772_1866627313400135_1510196954670301184_o.jpg
    touch: out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]
    any idea?

    1. You need to add one space after touch -t 201712120000, so the resulting command may be touch -t 201712120000 /Users/anytsujj/Desktop/33657772_1866627313400135_1510196954670301184_o.jpg

  10. Hi there! Thank you so much for this amazing post! I need help though… I think I have the command right but the date and time keep changing to the current date and time rather than the one I am asking for. Here is what it looks like:

    Palomas-Air:~ paloma$ touch –m -t 201904281734 /Users/paloma/Documents/MBC/PGarcia\ Invoice\ 12.06.2018.xls
    Palomas-Air:~ paloma$ touch –mt 201904281734 /Users/paloma/Documents/MBC/PGarcia\ Invoice\ 12.06.2018.xls

    None of these work! They all just defaulted to the current date and time 🙁 . I hope you can help!!

    Thank you 🙂

    1. What’s you MacOS version? Please see instructions for your version.

      touch –m -t 201904281734 works well for me in Mojave.

  11. Not sure if you can help or not. I am trying to change the date and time for clips to be used in iMovie. I actually HAVE changed the date. Initially, since I grabbed them today, the created and modified date were June 5 2019. I have changed them to the date I want for proper placement in iMovie which is June 10 2015. BUT, when I put them into iMovie, iMovie still sees them as being created today. The “adjust date” feature in iMovie rarely works anymore for me, frustratingly. I had use the touch command previously and it worked fine. But for some reason, it still sees a time stamp. Is there any other hidden time stamp in the file that you know of?

      1. OK…that looks cool and a bit complicated. I’m not even a baby Unix Terminal user, but I’m brave. So, in looking over the info for both links (plus a deeper link provided by one of them)….is the method to shift the date? Meaning, do I somehow put in what date I want to go to (eg, 2015:06:10) or do I need to tell exiftool to shift the date (eg, take the year back 4 years)?

        So, this looks like the latter: exiftool.exe “-DateTimeOriginal-=0:1:0 0:0:0” filename.jpg

        So, to go back 4 years, would it be exiftool.exe “-DateTimeOriginal-=4:0:0 0:0:0” filename.jpg

        But in your example to find out the date (and that was perfect…exiftool shows that there are several dates in the container still saying 2019), you only had exiftool, not exiftool.exe. So, with the above, is it

        exiftool.exe “-DateTimeOriginal-=0:1:0 0:0:0” filename.jpg

        or

        in Terminal do I simply put: exiftool “-DateTimeOriginal-=0:1:0 0:0:0” filename.jpg

  12. Not sure you got my last comment.

    The exiftool worked perfectly to show me the data on the file. As you thought, the container has several dates. There are 8 or 9 different time stamps. See below:

    ExifTool Version Number : 11.49
    File Name : 2015-06-10 Harwood-Watson1.m4v
    Directory : /Users/carlcreasman/Desktop/2015 Recital
    File Size : 25 MB
    File Modification Date/Time : 2015:06:10 19:00:00-04:00
    File Access Date/Time : 2019:06:06 17:30:52-04:00
    File Inode Change Date/Time : 2019:06:05 22:58:10-04:00
    File Permissions : rw-r–r–
    File Type : MP4
    File Type Extension : mp4
    MIME Type : video/mp4
    Major Brand : MP4 v2 [ISO 14496-14]
    Minor Version : 0.2.0
    Compatible Brands : isom, iso2, avc1, mp41
    Movie Data Size : 26256469
    Movie Data Offset : 48
    Movie Header Version : 0
    Create Date : 2019:06:06 02:13:10
    Modify Date : 2019:06:06 02:13:10
    Time Scale : 1000
    Duration : 0:06:22
    Preferred Rate : 1
    Preferred Volume : 100.00%
    Preview Time : 0 s
    Preview Duration : 0 s
    Poster Time : 0 s
    Selection Time : 0 s
    Selection Duration : 0 s
    Current Time : 0 s
    Next Track ID : 4
    Track Header Version : 0
    Track Create Date : 2019:06:06 02:13:10
    Track Modify Date : 2019:06:06 02:13:10
    Track ID : 1
    Track Duration : 0:06:22
    Track Layer : 0
    Track Volume : 0.00%
    Image Width : 853
    Image Height : 416
    Graphics Mode : srcCopy
    Op Color : 0 0 0
    Compressor ID : avc1
    Source Image Width : 720
    Source Image Height : 416
    X Resolution : 72
    Y Resolution : 72
    Bit Depth : 24
    Pixel Aspect Ratio : 32:27
    Video Frame Rate : 29.97
    Chapter List Track ID : 3
    Media Language Code : und
    Balance : 0
    Audio Format : mp4a
    Audio Channels : 2
    Audio Bits Per Sample : 16
    Audio Sample Rate : 48000
    Track 2 Name : Stereo
    Matrix Structure : 1 0 0 0 1 0 0 0 1
    Media Header Version : 0
    Media Create Date : 2019:06:06 02:13:10
    Media Modify Date : 2019:06:06 02:13:10
    Media Time Scale : 1000
    Media Duration : 0:06:22
    Handler Description : SubtitleHandler
    Gen Media Version : 0
    Gen Flags : 0 0 0
    Gen Graphics Mode : ditherCopy
    Gen Op Color : 32768 32768 32768
    Gen Balance : 0
    Other Format : text
    Warning : [minor] The ExtractEmbedded option may find more tags in the movie data
    Handler Type : Metadata
    Handler Vendor ID : Apple
    Encoder : HandBrake 1.1.2 2018090500
    Avg Bitrate : 550 kbps
    Image Size : 853×416
    Megapixels : 0.355
    Rotation : 0

    So, using the exiftool, do I make one single change and it will take care of all the options? Is that change to provide a new date applied to the container OR is it merely shifting the date?

    This info from one of the links you gave me seems to suggest the latter:
    exiftool.exe “-DateTimeOriginal-=0:1:0 0:0:0” filename.jpg

    1. Glad you’ve found the way to run it!

      `.exe` is a Windows addition, just drop it for mac.

      Looks like this command may help you: `exiftool “-AllDates+=Y:M:D h:m:s” filename.jpg` (change dates in it).

      If you want to run it on all *.jpg files in folder – you can do so:
      – go to needed folder: `cd /path/to/folder` (you can drag folder from finder to terminal and it will past it’s path)
      – run `exiftool “-AllDates+=Y:M:D h:m:s” *.jpg` , so *.jpg will get all .jpg files in folder and change them.

      1. So, for ex. `exiftool “-AllDates+=2016:01:01 01:01:01” *.mp4` changed dates in metadata for me to 2016, january, 1st, 01 hour 01 min 01 sec.

        1. Here’s what I got: Carls-iMac:~ carlcreasman$ ‘exiftool “-AllDates+=2016:01:01 01:01:01” /Users/carlcreasman/Desktop/2015\ Recital/2015-06-10\ Harwood-Watson1.m4v’
          -bash: exiftool “-AllDates+=2016:01:01 01:01:01” /Users/carlcreasman/Desktop/2015\ Recital/2015-06-10\ Harwood-Watson1.m4v: No such file or directory

          You can see that it came back without changing the file. I ran the basic exiftool just to double check and it did keep all the old 2019 dates. I wasn’t sure about the initial single quote mark that I used above (at the start and end), I tried it again without the single quote….and I got this.

          Carls-iMac:~ carlcreasman$ exiftool “-AllDates+=2016:01:01 01:01:01” /Users/carlcreasman/Desktop/2015\ Recital/2015-06-10\ Harwood-Watson1.m4v
          Warning: Value above int32u maximum for CreateDate – /Users/carlcreasman/Desktop/2015 Recital/2015-06-10 Harwood-Watson1.m4v
          0 image files updated
          1 image files unchanged

          Again, there was no overall change. So, I SO appreciate your guidance. THANK YOU…please keep teaching me. What am I doing wrong above?

Leave a Reply

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