Set Folder Mod Date to That of Latest Enclosed Item

I’ve just rebuilt my iMac and the mod dates of all my reinstated folders have changed to the date they were dragged back to the new SSD. I blamed Dropbox for three days, but it happens with local files too.

It’s folders only. Others have had this issue under 10.14.x it appears.

I’ve been trying to find an AppleScript to “get the date of the last-modified item in a folder then set the enclosing folder's modification date to match it".

I’m thinking, instead, of doing something in KM. I use it daily but can script about as well as I can fly.

I’ve discovered KM’s Get File Attribute and Set File Attribute but I don’t know how to tie them together.

I want to do this in the finder:

• open a folder (by clicking the wee triangle in list view, really.
• select a file (or nested folder) manually
• invoke a KM macro that:
1> gets the chosen file/folder mod date
2> goes up one level of heirarchy (if only by recording mouse clicks)
3> pastes the mod date into the enclosing folder
4> end
• repeat manually (i have maybe 300 folders to do; manual's fine… maybe an hour's work I reckon…)

Can anyone give me a clue about joining one and three please? Or if I’m better off doing it another way tell me to get stuffed.

Appreciate your help.


Fortunately, there is a better/more automatic way to do this than manually going up one level of hierarchy and pasting. This macro should automatically set the mod date of the currently selected folders to that of the last modified item in those folders:

Set Mod Date of Selected Folders to Last Modified File Date.kmmacros (4.5 KB)

Before Macro

After Macro

While this macro could be made even more automatic by modifying it to point to a top-level folder and letting it work recursively on sub folders, I imagine you might be more comfortable manually selecting the folders you want to change and confirming the results, especially since there's no easy way to undo the changes (plus, if I'm being perfectly honest, it would be too much trouble on my part to create a whole bunch of folders and sub-folders and fill them with files of different mod dates to test a macro like that :slightly_smiling_face:)


I was going to respond to this with a macro to answer @justcomingdear’s question, but @gglick’s solution is way better, which makes me very glad I pointed the OP to the forum instead of answering it myself!

Since I'd already done my solution, here it is, but almost certainly use @gglick’s.

Set Enclosing Folder Mod Date.kmmacros (2.6 KB)


Peter, Gabe

THANK YOU both for such prompt and, apparently, slick answers. I'm going to run another backup then try them this afternoon; report later.

Thanks again!


1 Like

Couldn't wait. Duped a couple of folders and tested the thing – Gabe's version, following Peter's self-deprecating comments…

Works beautifully.

Also, being vaguely OCD I colour folders using Erica Sadun's Folderol. Which is great but it sets the mod date of the folder to that moment, so colouring them retrospectively is a pain. I've been using some crappy date changing thing that takes a minute a go, having to enter the required date with popups rather than pasting or keying. So I've been colouring only significant folders. This cracks that. I can go wild. Fantastic. Happy to gift you guys a copy if you'd like?

Again, thanks…



Hey @justcomingdear,

Peter and Gabe have done a bang-up job of showing you how to do this task with Keyboard Maestro specific actions, so for fun I did it with a few lines of code in the shell.


Set Directory Modification Date to that of Latest Enclosed Item v1.00.kmmacros (3.0 KB)

1 Like

Hello Chris!

Hmmph. I'm selecting the parent [badly dated] folder and invoking the macro (I've tried various hotkeys as well as your F1) and apart from a 'ding' nothing appears to happen. If I use the "Try" button in the editor I get a notification as shown.

I'm delighted with Gabe's solution but very much appreciate yours. I'm posting out of courtesy and sharing my results not because I need any further work but simply in case it's of interest to you. I imagine I've done something wrong...

fresh os 10.14.5 (18F132) :: eyetv 3.6.9 7524 – not running :: KM 8.2.4

Thanks and best



Hey Al,


I believe your original post specified selecting an item contained in the parent folder.

What happens when you do that?


Hello again Chris

You're right of course.

Because Gabe's solution lets you select one (or multiple 'parent' folders at a time!!) then appears to get the date from the most recent (or selectably oldest) document contained therein I'd forgotten my original rather kludgy suggestion. Which was, indeed, to select one of the files inside the folder to be re-dated.

But to answer your question it sure appears that nothing happens at all (I tried it everwhichway I could think…)



Hey Al,

Well drat.

It worked fine here, before I posted it – but now it's failing...

Try version 1.01 below.


Set Directory Modification Date to that of Latest Enclosed Item v1.01.kmmacros (3.0 KB)


No problems so far – thanks man!


1 Like