Adding to Folder Triggers Action Twice

Hello!

I have a peculiar problem with a macro. I have an AppleScript saving a random photo from my Photos album to a specified folder, which KM observes and then triggers a macro whenever a new item is added. But each time I save an image to the folder via the AppleScript (not if I drag & drop a photo there), it triggers the action twice, creating some havoc in my macro (removing the file again, pausing statements etc.).

It is KM that somehow registers a save two times. I have debugged the AppleScript, so there is no saving twice there. Any idea why this is?

Cheers,
Massimo

Hey Massimo,

Set this macro to your folder path, and use it to see what the Folder-Trigger sees.

Most likely your save is occurring atomically, and both the invisible save file and the subsequently renamed file are seen by KM as separate file instances.

Frequently this can be worked around by filtering out files that start with a dot (.filename).

-Chris


Download Macro(s): Folder Trigger ⇢ Test.kmmacros (3.0 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

1 Like

Hey Chris!

Thank you for your kind help! I tried this only using your macro, but no problem was raised there. Then I copied the actions into my macro, and lo and behold, two images now appeared:

But, I observed from your macro that you had set the parameter "ignore partial or changing files" for the folder trigger. Changing this on my macro seems to do the trick - now no second image is appearing :smile::star: Eureka! I only had the "ignore partial files" option set. The system/Applescript is somehow changing the file's name, and that was the culprit.

Thank you again. This was very helpful!

Cheers,
Massimo

1 Like

I'm glad you're observant.

I intended to turn off partial and changing files, so you'd get the full full monty.

Take note of this technique – it's troubleshooting 101 for Keyboard Maestro.

Breaking things down to the simplest possible data and looking for anomalies.

The text window is a gem for this, and keep in mind that you can set the font and front-size in it for easier viewing.

1 Like

Thanks again, Chris! The same issue was also causing problems in other macros, such as backing up files with extended attributes. Changing this now ensures all files are "done" before they move on in the scripts. Cheers!

1 Like