How to re-run actions?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

How to re-run actions? Thu Mar 18, 2010 5:52 am • by alastor933
I'm working on some scripts that will be run by a rule like this:

IF
(conditions)
THEN
set label to none
run script
END

All scripts open the file to read its content, and do useful things with the data.
When a script completes, the unlabeled file is either relabeled (with a different label), deleted, or moved elsewhere.
Any uncaught script error will make Hazel run the rule again. This is not useful to me, as the cause of foreseeable errors will not go away with the passing of time. So scripts must catch all errors, and send an email to user to inform them about what happened.

When an error occurred the user should resolve any problem and reset the label, to tell Hazel to run the same script again.
But Help tells me:
If a file matches the same rule it matched last time, it will not re-run its actions


I'm thinking the user could drag the offending file out of its folder, wait a little, then put it back. Hazel will see it as new, and rerun the rule.
Is there any other way? Does 'Run rules now' run actions regardless of the rule having matched previously?

How much time should pass to make Hazel see the file as new? (Make a rule on that other folder to move the file back.)

Note: scripts run on a Mac that's on its own - no user present.
The labels, and the way they change, are an integral part of the workflow. I *have* to use them.
alastor933
 
Posts: 53
Joined: Wed Mar 05, 2008 3:52 pm
Location: Utrecht, Netherlands

Re: How to re-run actions? Thu Mar 18, 2010 12:40 pm • by Mr_Noodle
Yes, "Run Rules Now" forces the rules to run even if that had already run on that file before. Note that this runs the rules against all files in the folder. If you need to do it to one file without running the rules on the others (i.e. running the rules again on the other files would have undesirable side effects), you could pull the file out and then put it back in. I would wait a minute or two in between just to make sure Hazel realizes the file was pulled out. Note that if you do this too much Hazel may stop processing the file until after a cool-down period. This is a case where Hazel thinks there is some sort of loop (rules that are popping the files back and forth) so keep that in mind.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: How to re-run actions? Thu Mar 18, 2010 4:52 pm • by alastor933
Yes, "Run Rules Now" forces the rules to run
Ah good, that makes it quite a bit simpler.
i.e. running the rules again on the other files would have undesirable side effects
I think I'm safe here. Hazel does not set labels, only the user does. While he's solving a problem he won't be changing labels on other files.

Having Hazel clear the label that triggered the rule is a safety net; when unlabeled files linger it's a sign that something went wrong, even when the email that should have been sent never arrives.
And in this context it prevents rules running again where they have already run, as the triggering label was removed by the rule itself.

Errors in the error handler (yuck!) should still show up in Hazel's log.

Thanks again.
alastor933
 
Posts: 53
Joined: Wed Mar 05, 2008 3:52 pm
Location: Utrecht, Netherlands


Return to Support