[DATE] Change Creation and/or Modification Date of Selected Finder Item

MACRO:   [DATE] Change Creation and/or Modification Date of Selected Finder Item

VER: 2.0    2016-09-10 ~~~

2016-09-10 15:24 CT (Sat)

Changes for Ver 2.0

  • Added support for Yosemite
  • Added check for non-supported macOS's
  • Added support for ISO / International Date format
  • Added support for Folders
  • Changed Macro Name to indicate support for all Finder Items


[DATE] Change Creation and-or Modification Date of Selected Finder Item.kmmacros (25 KB)
It is best to delete the old version before importing the new version.

Notice of Attribution

@ccstone (Chris) and Shane Stanley deserve all of the credit for the script this macro uses.
All I did was to add a script handler/wrapper, and embed in this macro.
Many thanks to these guys for a terrific, very useful, script.



PURPOSE: Set the Creation and/or Modification Date of Selected File


  1. Select a File in the Finder
  2. Run this macro

TAGS: @Dates, @Finder, @Files, @ASObjC, @ccstone, @ShaneStanley


  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Varibles or Clipboards


  1. Keyboard Maestro Ver 7.2.1+
  2. mac OS Yosemite (10.10)+

By downloading or installing this software, you agree to the terms of usage in the "License and Usage Agreement" at the bottom of this page. Do not install or use if you do not agree.

Example Prompt for Input

License and Usage Agreement

Copyright (c) 2016, JMichaelTX

By downloading or installing this software, you agree to the following statements.  DO NOT INSTALL OR USE IF YOU DO NOT AGREE.


  1. "Software" refers to any and all data and computer software related to this Keyboard Maestro Macro, including, but not limited to: instructions, macros, actions, plugins, scripts, and resources . It includes everything in the download file(s).

Permission is hereby granted to anyone to use, copy, and/or modify the software. The software may be redistributed provided that: (1) It is offered free of charge to others; (2) The following are included in and appear in all copies: (a) The above copyright notice; (b) This License in its entirety; and (c) Attribution is given to the original author named in the above ReleaseNotes.

The software is provided "as is" and the author disclaims all warranties with regard to this software including all implied warranties of merchantability and/or fitness for a particular purpose.

In no event shall the author or Copyright holder be liable for any special, direct, indirect, or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software.


Just posted update.

Is there a way I can enter the exact time (minute, second, etc)? Also is there any way to set the creation to the current time? (Basically the equivalent of putting the results of %LongDate% %LongTime% into the macro because I’m not sure I’m making sense).

Thanks! Great macro.

Just posted an update.
It is best to delete the old version before importing the new version.

Yes. Just enter it in a format that AppleScript understands, like this:
Jan 1, 2000 1:00 pm

Not automatically, but easy enough using some text expander, like Keyboard Maestro.
Just create a macro that outputs the current date/time, and run it when you click in and clear the New Date box.

Of course, you can always just enter it manually. :wink:

Hi It s great really. But I need to apply this macro to more than 100 files at a time. How should I modify this one? Like using each item on the collection action.

Thanks :slight_smile:

You need to change the script in this Action:

###Script Changes


set itemPosixPath to POSIX path of (item 1 of itemList)
set returnResults to "OK" & return & my changeDate(itemPosixPath, dateToChangeStr, newDateStr)


set returnResults to "OK" & return

repeat with oItem in itemList
  set itemPosixPath to POSIX path of oItem
  set returnResults to returnResults & my changeDate(itemPosixPath, dateToChangeStr, newDateStr) & return
end repeat

This will change ALL files to the same date that you enter into the Prompt.

Thanks it works like a miracle!

1 Like

Is there a way to set the microseconds (milliseconds) with this macro? It seems to ignore them.

When I try to set the mod date to: 2018-02-05 13:38:2999 the Finder shows 2018-02-05 13:38:000

Need this because I’m using the microseconds to sort the files properly.

Keyboard Maestro passes the number as is to the system, with fractions included, and displays any fractions the system reports to Keyboard Maestro (in the Set/Get File Attribute actions). So if that does not work for you, then I would guess the system does not really support it.

I have just been testing both Set/Get File Attribute actions getting the Mod Date with unexpected results. e.g.

  1. On File1 – GET Mod Date = 1517801887 (but it truncates any milliseconds out compared to what I can see in Finder) and I load it into GETMD variable

  2. On File2 – SET Mod Date = %GETMD% + 0.5 = 1517802089 (as expected - its added the 0.5 in. i.e. the milliseconds are set properly - and they show in the Finder)

Shouldn’t File1 be getting the milliseconds as well from the GET Mod Date? They do exist as I can see them in the Finder.

Clearly, the API Keyboard Maestro ([NSFileManager attributesOfItemAtPath:error:]) uses does not deal with returning sub-second times.

It is possible the API does allow setting then dates with sub-second times, which is why you see that working.

Sorry, you’ll need to find an alternative way to get the modification date with sub-second accuracy.

Hey Steve,

Please explain how you're seeing milliseconds in the Finder.

Edit: 2018/03/17 04:14 CST

Whups – I know how to make the Finder display milliseconds in a date, but I'm not aware of any software on the Mac that takes advantage of this and actually saves the date to that level of precision.

How are you achieving this?


There’s a setting in Mac System Preferences where you drag extra resolution fields to show in Finder.
It reflects across the Mac if you do this e.g. in Mail.

Could you please provide the path to this setting, and/or a screenshot? I can't seem to find this setting in either SP or Finder Preferences running macOS 10.12.6.

It’s in system prefs->language & region->advanced->times.

OK, thanks, I found it.

Just to make it clear to all:


Hey Steve,

Yes, I mentioned that I knew how to do this.

The issue is that once it's done I do NOT see any dates with sub-1-second precision.

Not any existing file/folder dates.

Not any newly created file/folder dates.


(I had not seen your edit as I was reading by email.)

I updated the milliseconds using KM. Used the milliseconds to change the file sort order.

2 posts were merged into an existing topic: Copy Creation Date to Modification Date of Finder Selections?