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

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?

This macro no longer works for me in Catalina. It executes, but dates on folders remain unchanged while dates on non-folder items selected in Finder change to the 1st of the current month and year. Does it work for anyone else?

Sorry, since I'm running Mojave, I can't really help with Catalina, other than to suggest that it might be some type of permissions issue. You might try running the script (modified to use a manual date) in Script Editor, and see if that works.

Hi JMichael,

Just a quick question regarding this macro. I am running Monterey and am based in the UK. The script ran perfectly except for the resulting date.

I ran a test on a single document in finder, when the pop-up window presented I inputed my desired date in ISO format (YYYY-MM-DD) but the resulting date was 2033 instead of 2020. The day and month was also incorrect.

screenshot 2021.

In the time that you last posted this macro have you by chance updated it to work on the newer OS? If not, is there a relatively simply fix you could provide?

My original intention was for KM to read the contents of the markdown document and find the date (YYYY-MM-DD) and save as a variable to change the date this way -- but this is way over my head. Thus the interest in this macro. A little more of a manual process but hopefully with your help I can get it to work.

Thank you for your time in advance, it is much appreciated as always :slight_smile:

Hey Shande,

Unfortunately JM will not be answering you – in this life at anyway.

The Passing of JMichaelTX

JMichaelTX – Unforgettable Generosity With His Time and Knowledge


1 Like

I am very saddened to hear this. He was a wonderful person :cry: