Wait for 2 files w/same name (different extensions) to land in a folder, then move both

I couldn't find anything on the forum for this & it's looking more detailed than the basics I know regarding the 'If Then Else' action (but I'm a KM novice so I don't know for sure). So I'm wondering if anybody might have a clever way to do the following (I made a screencast showing what I'm talking about if it helps):

Password for the video: keyboardM

  • I have two folders on my desktop, one named 'INPUT' & the other named 'OUTPUT'

  • I have a continuous stream of .mp4's & .jpeg's that arrive in the 'INPUT' folder from different sources and at different times.

  • The format of the filenames always looks like this: A123456.mp4 & A123456.jpg

(those filename numbers always change but there will always be a mp4/jpg pair with the same name eventually)

  • I'm hoping to get KM to see when two files with the same name are in the 'INPUT' folder at the same time (one an .mp4 - the other a .jpg) and when there is a match, move both to the 'OUTPUT' folder.

Any help would be much appreciated!

This may not be exactly what you need, but it should get you started.

As always, please feel free to post any comments, issues, and/or suggestions you may have concerning this macro.

MACRO:   Move Pair of Matching Files in Trigger Folder [Example] @Bash

~~~ VER: 1.0    2018-08-15 ~~~


Move Pair of Matching Files in Trigger Folder [Example] @Bash.kmmacros (14 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.
Be sure to Change the Trigger to the Proper Folder before you enable it.




  • Move Pair of Matching Files from Trigger Folder


  • Since this macro is triggered ONLY when a file is put into the Trigger Folder, all you need to do is before you ENABLE this macro:
    1. Confirm/Set the Trigger Folder one time
    2. Confirm/Set the Output Folder
    3. Confirm/Set the File extensions to be used.
    4. Then, enable the Macro and test it.

NOTICE: This macro/script is just an Example

  • It is provided only for educational purposes, and may not be suitable for any specific purpose.
  • 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.


  • 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:
  • Change the Trigger to the Proper Folder
  • Move this macro to a Macro Group that is only Active when you need this Macro.
  • ENABLE this Macro.
    • ALL Actions that are shown in the magenta color
    • SET to YOUR Output Folder Path
    • IF: File is Proper Type, THEN Process
      • Confirm/Change Valid File Extensions to Use


  1. KM 8.0.2+
  • But it can be written in KM 7.3.1+
  • It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
  1. macOS 10.11.6 (El Capitan)
  • KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees. :wink:


  • While I have given this limited testing, and to the best of my knowledge it 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.


Wow!!! This works perfectly!!! I can't thank you enough. I'm going to be studying closely how you did this, it's a great learning tool and a huge breakthrough for me - hugely appreciated!!!

1 Like

You're very welcome, and feel free to ask any questions about it.
I'm sure others will have the same questions, so you'd be helping a lot of people. :wink:

1 Like