@Files Open List of Files in Folder Matching Criteria @Example

MACRO:   @Files Open List of Files in Folder Matching Criteria @Example

2017-06-16 21:43 CT

VER: 1.2    2017-06-16 ~~~
• Changed ShellScript to add option to limit search to only specified folder (no recursion)


@Files Open List of Files in Folder Matching Criteria @Example.kmmacros (23 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

Use Case

Example Results

Suppose you have a folder "Another Snare" with these files:

You need not select the folder in the Finder, just trigger the macro, and you will get a Choose Folder dialog:

where you can then select the Parent Folder.

Then you will be prompted for the Keyword to search for in the related file names:

Choose the keyword you want.


Then the macro will search and select the files with this keyword, and open them in your chosen app:




  • Open Files Found in Folder with KeyWord

NOTICE: This macro/script is just an Example

  • It has had very limited testing.
  • You need to test further before using in a production environment.
  • It does not have extensive error checking/handling.
  • It may not be complete. It is provided as an example to show you one approach to solving a problem.


  1. Just trigger this macro
  2. Choose Parent Folder
  3. Choose KeyWord
  4. All files found will be opened in your chosen app.


  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. :wink:
  • Assign a Trigger to this maro. I prefer TBD.
  • Move this macro to a Macro Group that is only Active when you need this Macro.
  • ENABLE this Macro.
    (all shown in the magenta color)
    • SET DEFAULT for Parent Folder
    • OPEN File in Chosed App

TAGS: @Search @Files @Folder @Keywork @ShellScript


  • Any Action in magenta color is designed to be changed by end-user


  • 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 Variables or Clipboards,
    OR IF/THEN and PAUSE Actions


  1. Keyboard Maestro Ver 7.3+ (don't even ask me about KM 6 support).
  2. El Capitan 10.11.6+
  • It make work with Yosemite, but I make no guarantees.


  • While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

1 Like

Just made an update.

Hey man!

This is awesome! Thank you so much for creating this! I wish you were in LA I would take you out for a drink or something! This is an awesome foundation for searching. I’m working on implementing it now. Fingers crossed

1 Like


Here is another change you need to make:
Change the ShellScript to:
find "$KMVAR_GLF__FolderToSearch" -maxdepth 1 -name "*$KMVAR_GLF__KeyWord*"

so that it includes the -maxdepth 1 option to prevent recursive (subfolder) searching.

I'll update the actual macro later today.

@Evil.Beasts, as promised, I have updated the original post/macro.

Thank you very much. Do you recommend any particular guides to start creating scripts?

Depends on the type/language of scripting you want to learn.
You might look at:

If you don't already know AppleScript, then I would suggest you start with JavaScript for Automation (JXA). It uses the same core JavaScript that has long been used in web browsers and thus has a lot of rich functions and wide support. You can find topics here by viewing Topics tagged with "jxa".