Folder Trigger – Behavior When Multiple Items Are Added to the Target Folder

If the macro is executed, the same macro cannot be executed within one minute. Can you make that IF THEN?

I am creating a macro that automatically uploads files to online storage. I want to use a file detection trigger at that time.

I'm trying to use a folder trigger. However, when multiple files are put, the macro triggers as the number of files.

In this case, can I trigger a macro only once?

I do the same as the number of files added.

My mac os is Monterey 12.6.2
KM Ver 10.2

So, when multiple files are added to the watched folder in one go, you want your Macro to just run once and not multiple times?

One way to do that is to have the Macro disable itself and then after a pause enable itself again. Adding a Semaphore lock as well at the start will stop any of the other instances of the Macro starting up. In the example Macro below the pause is 5 seconds - but you could make the pause longer (like the 60 seconds you mentioned) if you might be adding more files in that time and you don't want the Macro to react to them.

EXAMPLE Trigger just once when multiple Items added.kmmacros (4.8 KB)

Click to Show Image of Macro

2 Likes

Exactly as it is supposed to:

Your problem here is how to manage your copy/move job in the Finder.

You'll need to wait until the Finder is finished doing its thing, before you start the upload job.

The macOS should have a really easy way to detect this, but I'm not aware of one.

I would probably use du in the shell to wait for the directory size to stop changing and then add a pause to boot.

1 Like

Hello! how are you? Thank you for your comment again.

This macro is really wonderful. But there is only one drawback. It depends on the following action depending on the waiting time. For example, when I send a large amount of files to the specified folder (PSD, Raw etc), I have to specify a significant waiting time. As a result, the time to start the trigger is significantly delayed. To solve the problem, I want to introduce an action that recognizes that all files have been transferred using "Pause Unitil" or "if". is it possible?

WOW! That's a really wonderful macro Thank you!! As I told @ccstone If you can replace the waiting time to another command, it is really great. Do you know how to do that?
Thank you again!

This is what I suggested in Post #3...

I think I've got an example based on @Zabobon's macro working correctly now.

  • The macro currently displays some details about the operation upon conclusion.

Trigger Just Once When One Or More Items Are Added to the Given Folder v1.00.kmmacros (12 KB)

Display-Macro-Image

  • Take careful note of the fact that the path in the trigger and the path in the Execute a Shell Script action MUST be the same.
  • Any spaces in the path in the execute shell script action MUST be escaped.
    • I.e. /This path/must look/like this
      • /This\ path/must\ look/like\ this
      • Note the backslashes before every space (known as an escape).
1 Like

Trigger Just Once When One Or More Items Are Added to the Given Folder v1.00.kmmacros (17.1 KB)

Thank you for taking the time for me. It's a really wonderful macro. And it's really intelligent. However, I didn't know how to set the original action. I will provide you with my edited macro. If you have time, can you check what's wrong?

I'll try to help you.

Can you please tell me exactly the problem you want to solve with this macro?

Thank you for your kind words.

I just want to check if the macro in the current photo is correct.

Yes, well – the macro is a bit complicated and contains Japanese.

Spending an hour or more puzzling out what the macro is doing isn't on my agenda – so having a summary of what the macro is doing and where it is failing would be helpful.

1 Like

I apologize to you when the macro contains Japanese :joy:
also that's a very smart opinion. I am grateful for your wonderful support. I want to continue using this macro :pray:

That's nothing to apologize for – it's a simple fact that makes it more difficult for me to decipher your macro.

Language barriers always add friction to communication...

1 Like