Get most recent file modified in embedded folder structure

I know how to get the most recent file at the top level of a folder.
I have a number of embedded folders in the 'master' folder, and would like to find the file that was most recent within the seven embedded folders.
I could to it 'long hand' and first get the folder, then get the file, but curious if there is a 'short hand' way to do it.

Funny, I was looking for something similar this morning. I'd like to pull a list of files created in the last n hours, regardless of location. I came across this macro from @ccstone: Pick-List of Items Modified in the Last 24 Hours that I thought I would tweak for my use, but it threw an error for me out of the gate and I didn't go any further. Maybe it will give you something to go on.

1 Like

Hey Evan,

This should get all files on your boot drive modified within the last hour:

shCmd="mdfind -onlyin / 'kMDItemContentModificationDate >= \"\$${HOURS}h)\"'"
eval $shCmd

You can use a Keyboard Maestro variable in the shell script like so:


That will let you change the number of hours in the macro proper, instead of having to do it directly in the shell script action.


1 Like