Select the 10 Most Recently Added Files in Folder (Finder)

Hey Folks,

I am a big fan and user of the Sort/Selection functions to get the most recently added or modified file within a path or Finder selection, and I was wondering if it is possible to open and select 10 (or whatever number) of the most recently added files within a specific path? I only know how to get it to upon and select the first most recently added/modified file

Add a counter inside your For Each action (like Set Variable to Variable + 1) and make the macro abort when the counter reaches 10.

How would I get it to then open Finder and select those 10 files within the same window?

Yes, you are right, I only answerded to the “10 most recently” part of your question.

Do you want to open or select them? (Asking becuse in your OP you have said “to open and select”.)


With an Open action.


Why do you want to select them? You can tell KM to do anything with those 10 files without selecting them before.

Sorry, I meant to open the path they are located at, and select them within finder (so I can drag and drop them into the browser of somewhere else if need be).

This will reveal and select the 10 most recently added files of a given folder in the Finder:

Reveal and Select the 10 most recently added files in the Finder <8DAB 200225T234059>.kmmacros (5.0 KB)


  1. Make sure macro and macro group are enabled.
  2. Set a hotkey trigger or add the macro to a palette.
  3. In the For Each action replace the ~/_Tmp ƒ with your actual target folder path.
  4. Run the macro.

Update (2020-02-25):

  • Forgot to select the Reversed checkbox in the folder collection

@Tom, I really like your Macro. I have an AppleScript that will do this, but in this case the ASObjC is so complex it turns out that using KM is shorter and simpler.

Well done! :+1:

Just one little glitch: I believe that your macro returns the 10 Added the LONGEST AGO files, rather than the 10 MOST RECENT files:

At least that's how it works for me running Keyboard Maestro 9.0.5d1 on macOS 10.14.6 (Mojave).


@DrSabs et al:

Rather than hard coding the source folder path, you can also use either of these Actions:


Alternate Actions for Get Source Folder (v9.0.5d1)

Keyboard Maestro Actions.kmactions (813 B)

Importing these ACTIONS will insert them immediately after the selected Action in the current Macro being edited.

Oh, yes. Thanks for the hint; I have corrrected my macro above.

All good options. Thanks guys, these did the trick!