Perform an Action 24 Hours After File Creation Date

I've written a macro to move a folder 24 hours after it's created. I do it by setting the variable timeDifference to NOW - creationDate (which I got from a previous step). I can see that the current value of timeDifference is 161333 seconds and since I want to wait 86400 seconds (24h * 60m * 60s), I've added an if-else action with the condition timeDifference >= 86400 but for some reason it says that it's currently false:

image

What am I doing wrong?

Any help with this? I still can't figure it out. :sweat_smile:

You've used NOW in the calculation, but that means nothing to KM.

You should be using NOW() like in:

NOW()-creationDate

You can also use TIME() as that's the same as NOW()

See the wiki page https://wiki.keyboardmaestro.com/function/NOW

I'm afraid that made no difference, but thanks for the suggestion.

Any other ways I can debug this?

image

I tried something similar to your macro here and noticed something odd.

Here is my first attempt:

KM 1 2020-12-08_11-42-52

I just replicated yours using two different variables and got your erroneous result.

What I did then was to actually run my macro and this is the result:

KM 2 2020-12-08_11-56-14

You can see that after running the macro, I get the expected (correct) result. I can't explain why that happens but maybe things involving calculations don't actually "happen" until the macro runs. So if you made the change to NOW but haven't run your macro here's what I suggest:

  1. Run your macro and see if that makes a difference.
  2. Put a Display Text action before the If statement to show the value of the timeDifference variable.

If there problem's still there, screenshot your macro with the display of the timeDifference value and submit a bug report.

1 Like

Interesting. I have it set up with a time trigger:

image

But I tried your method (I added a shortcut trigger) and it ran.

Now that I think of it, the problem might be caused by the for loop I'm using:

image

Maybe @peternlewis can help us out.

Why would you say that? It looks OK to me.

Looking at this image:

KM 1 2020-12-08_11-42-52

You need to understand what the boxed areas mean:

current value ➔ currently calculated value

So from that, going through the highlighted boxes we learn:

  1. VarName is currently empty. NOW()-1606909875 is currently 518641.
  2. VarName, which is currently empty (see 1) is not >= 86400.
  3. timeDifference is currently empty. NOW()-1606909875 is currently 518641.
  4. timeDifference, which is currently empty (see 1) is not >= 86400.

What I did then was to actually run my macro and this is the result:

after you run the macro, VarName and timeDifference are set to the values of the calculation (a number slightly larger than the 518641 above because a small amount of time has passed).

Now VarName and timeDifference is >= 86400.

Keyboard Maestro (editor) is no live running/simulating your macro. Each action shows only the current values of inputs and outputs and true/false results.

1 Like

Thanks, Peter. Is there something wrong in my workflow? I've set the trigger to be every day at 5am but it doesn't appear to be running:

image

Thanks @peternlewis. That’s crystal clear now!

Check whether it is running at all - you can look in the Engine.log file (Help ➤ Open Logs Folder) to see if it is being triggered at 5am. Or use the Macro Inspector to check if it was last used at 5am.

Remember that Keyboard Maestro cannot do anything if the Mac is sleeping. And many actions will not work if the screen is screen sleeping, screen saving or screen locked.

1 Like

Mystery solved. Thanks, Peter. I think that was the problem.

1 Like