i have a problem with figuring out how to write smart rules that should be exclusive. Goal is to rename records.
there is a generic component here (modified date, removing extension, lowercasing everyhing)
the problem now is that it seems the smart rules are executed randomly and independently. creating smart rules that are mutually exclusive to each other seems tricky and error prone.
In hazel the order of the rules within a directory matter and you can cancel the execution of the directory. that makes quite a bit of sense as you are basically looking at rules as a function, in a way. in DT you cannot do that it seems but you also don’t have if-else statements
how are folks solving this?
Without seeing the smart rules you define, it’s near impossible to help you.
i don’t know how to define it
this is what i have but obviously this is the generic case if none of the other parameters match (brand name etc)
Posting something that is not related does not really help. I do not even understand what your problem might be – did you try to define smart rules that do not do what you want? Then please show them. Do you not know how to define the smart rules that do what you want? Then please give a step by step description
- what your input looks like
- what you want your output to look like
As to the screen shot: Why would you do OCR on something that has a word count > 20, so presumably already a text layer? If you do not OCR these documents, why use the trigger
On OCR? Why do you use
Before Synchronization? Do your documents come from another DT installation?
Same in DT; smart rules are executed top to bottom; if a smart rule triggers and contains the Cancel action, no further smart rules will be applied.
That’s odd because it executed the last rule first I think. But didn’t know, I will test some more. Thanks
There is an exception to the execution by order and that’s interval triggers.
An interval starts at the moment the Smart Rule is saved, both for the first time and for every time it gets edited later.
So when you have two Smart Rules with the same interval trigger, say Every Hour, it is the Smart Rule you saved earlier that gets executed earlier, its position in the order notwithstanding.
i can’t seem to make it work. they are definitely not applied top to bottom. my top rule has a cancel and yet the bottom one is applied. trigger is as shown above in the screenshot
edit: i think i just stumbled across a bug. i duplicated my rule and that seems to reset the triggers. didn’t notice but that explains why i couldn’t get the order to work cc @BLUEFROG
i do not know how to structure my smart rules. it is an architectural question i guess
i showed the input and output above. as described above, what i would like to do is something like this
generic step 1
generic step 2
if data contains bmw
else if data contains audi
else if data contains tesla
generic step 3
generic step 4
do C could be anything. but lets keep it simple: i want to add tags and change the name.
screenshot, though specifics aren’t relevant as you can see from my above reply:
- i don’t do OCR on it in the rule
- might be the wrong trigger, i thought it would run the rule after the OCR
- why not use before sync?
- can be, yes.
would this also apply to sync related triggers?
No; they are applied top to bottom.
You have shown the required structure yourself. Place your rules in the order you showed in that post; don’t use the Cancel action until the last generic step (or maybe you want the rules to cancel if the brand-specific rule triggers? Then include the Cancel action there, too). Because you can’t do if else, each one of BMW, Audi, Tesla need their own rule. The on OCR trigger will only run if OCR is triggered manually (or by the OCR action in a rule, I think), but not by OCR triggered as part of the import process by the appropriate setting in the preferences. If you want to trigger your rule as the document arrives in your inbox, use on import (which will run after OCR has been performed, if OCR is set to run in the preferences). If you are collecting documents with DTTG and want to run your rules once the documents reach your Mac, use after synchronisation.
I use scripts for complex rule actions; so I would actually only write one rule for what you are doing, and script the actions. I only really do that because I don’t like having that many rules (subjective) and can’t in any way catalogue the rules (e.g. putting the rules you describe into a folder car rules).
That is not a bug, but intentional; new rules are set to on demand by default; that way they don’t do anything until you have finished setting them up. Rules are powerful - you could, for example, easily and irreversibly rename every single document in your databases cat…
As @Blanc pointed out, you can’t do
if-then-else in rules directly, so one possibility would be to have different rules for each “if data contains” step. An alternative (a better one, in my opinion) would be to use an AppleScript for that. Have it scan the plaintext of the document for the terms you’re interested in and then act accordingly. I’d probably have the script run as the last step, so that it can do everything not possible or not simple with smart rules.
Having separate rules seems a bit error prone to me, especially since you have to reproduce the steps 1 through 4 for each of them. If there’s an error in one of these steps, you have to correct it for every version of the rule.
i really dislike applescript and moved on from it. i won’t be creating new functionality with it, especially now that omnifocus is using omnijs.
the problem with hazel is that i wouldn’t be able to use DTTG i assume? i would have to put the pdfs i find onto dropbox and kick hazel off. hazel and my dropbox folder are unfortunately unreliable as hazel doesn’t seem to trigger correclty for new files at times. getting it straight into DTTG would be much easier.
actually, @Blanc makes it sound like steps 1 to 4 could be handled by ordering the rules correctly.
it is a duplication though, the rule is already running…
I understand that; but in general a duplicated rule will be one which you still want to edit (as you wouldn’t typically need two completely identical rules). It’s a safety mechanism which always applies. We can be of differing opinions as to whether it should apply without exception, but I don’t think it’s a bug
ok thanks for that. couple question on this:
- would the BMW rule not have to also include the other rules but inverted? ‘text contains BMW and NOT AUDI/TESLA’ ?
- the rules need to make sure to not run again on already seen documents or is DT keeping tracked of this?
- i am still slightly unsure how i trigger after the automatical OCR process finished?
- when you say scripts, do you write applescripts and use those in the action steps of the smart rule?
The problem with smart rules in DT are that they do not work in DTTG, so that’s pretty much the same situation.
You could put the PDFs wherever, preferably a local folder that Hazel is watching. I use a folder in iCloud Drive for that which works reasonably well. Also, the documents are moved from there into DT, so no residues, no space consumption.
I doubt that any smart rule will get you anything “straight into DTTG”, though
what i meant is that quite often i import into DTTG first and it gets synced to DT where the smart rule runs. with your approach i won’t be able to import into DTTG because i need hazel to run on the files. will have a look at idrive, maybe thats more stable. thanks