Page 1 of 1

Run multiple rules per item even if some don’t fail

PostPosted: Fri Apr 23, 2010 3:53 am
by DivineDominion
A few recent topics seem to tackle the very problem I have with understanding Hazels inner structure. The order of rules is important, as I understood. But what if I want to run more than one rule on a file but cannot write a convenient condition which checks for past rule matching (to fail and go down one step in the rule hierarchy)?

Situation

I’m currently monitoring a digital archive folder, which contains various notes, reflections even important e-mail copies. My naming conventions enable me to distinguish between a few categories to which I apply color labels accordingly.

Now, there will be another dimension added to the flat, chronological order. Whenever a file’s sub-category or tag (think of OpenMeta tags, as in Tags.app, Yep, Leap, …) match a certain pattern, a shell script will be executed to create a hard link in a subfolder of my archive. This adds zero functionality but enables me to browse these category-independent "notebooks" (collection of the aforementioned tagged/sub-categorized items) from the file system.

One item can have multiple "notebook"-tags and should be linked from all of those subfolders. As soon as one rule matched, further matching is omitted. I can’t just insert a condition which checks against existence of a hard-linked entry in the corresponding subfolder and, if there’s already a link with the same file name, skip that rule. That’s because I check agaist "any" conditions, not "all", to be able to both check for tags and a specific file naming pattern.

Example matches

A possible file name:
Code: Select all
2010-04-22_0931_T2-1-nix_Some Shell script idea.md

The category is "T2-1-nix" which shall be linked to the "nix" subfolder because it indicates this file’s a Mac/Linux/*nix script I wrote. Now an e-mail from my old pal Foo Bar concerning scripting ideas might be filed as
Code: Select all
2010-02-05_0123_M1-2-foobar_Fancy technique.md

This entry shall belong to a person-based "foobar" subfolder, but content-wise, it’s tagged something similar to "notebook:nix". So my "*nix notebook" rule checks for a file name pattern like "(...)-nix_(...)" or for tags containing "notebook:nix".

Re: Run multiple rules per item even if some don’t fail

PostPosted: Sat Apr 24, 2010 3:19 am
by DivineDominion
Yeah, it’s kind of stupid to report an applications feature as a cause of problems. So I thought about it again:

Is there a way to ensure multiple rules are processed equally?, which means: Even when all of them potentially match, execute each of them once.

I’m thinking about “Date Last Matched” concerning each rule, not a folder-rule-set, i.e. enabling to check a file against a match of single rules.

Re: Run multiple rules per item even if some don’t fail

PostPosted: Sat Apr 24, 2010 7:16 am
by Gnashing Teeth
Yeah, it’s kind of stupid to report an applications feature as a cause of problems.


Don't beat yourself up. You're not the first nor will you be the last to be confused by the subfolders functionality in Hazel. Mr. Noodle does his best, I have no doubt, but the sticky post that purports to explain this functionality is not well-written. Plus it has changed over time with different versions of the app. Thus I have had to revise old subfolder-dependent rules that worked fine a year ago, then got broken by a new version. Trial and error works if you stick at it. Hazel is a nice app, and the functionality is there, but you must sweat to get at it in some cases.

Re: Run multiple rules per item even if some don’t fail

PostPosted: Sat Apr 24, 2010 2:57 pm
by Mr_Noodle
DivineDominion:

Unless I'm misunderstanding what you are trying to do, it looks like you just want compound conditions, like being able to nest subexpressions in the conditions. Something like "If (A and B) or C. That is being implemented for 3.0.

Having multiple rules match would be a bad idea. Most people do not expect rules to fall through and requiring adding a "Stop processing" action to all your rules would be tedious. If anything, doing multiple rule matches against a single file would be more the exception. In such a case, I would consider a "Continue processing" action with single rule matches as the default.

Gnashing Teeth:

I have to say that I'm boggled by your statement. I do not recall the subfolder functionality changing in such a way as to break old behavior. If you could point to specific examples, I'd love to hear it as I've had no reports of this in the past. I have added things like Subfolder level and such but these only extended, not broke, existing functionality.

I will admit it is a bit confusing but it does maintain the level of flexibility required for the feature. The single checkbox idea sounds great on paper but would really screw up people's files. When used improperly, it can end up "unfiling" all the files in your carefully laid out hierarchy. If you feel the article is not well-written, please provide specific areas of improvement so I can address it.

Re: Run multiple rules per item even if some don’t fail

PostPosted: Mon Apr 26, 2010 2:08 am
by DivineDominion
Mr_Noodle wrote:Having multiple rules match would be a bad idea. Most people do not expect rules to fall through and requiring adding a "Stop processing" action to all your rules would be tedious. […] I would consider a "Continue processing" action with single rule matches as the default.


"Continue Processing" sounds nice. Another idea would be nested rule subsets, but that’s just a spontaneous one and may not be so good after all.

I think I could de-Hazel my problem if I just ran a script on each file which sorts the notebook-items dynamically, i.e. extracts any "notebook:*" tag and sorts a hard link into a subfolder that is named after whatever the asterisk matched. But then I won’t use Hazel for this feature, but well, probably I needn’t to :)

I’d like to have a more precise documentation on Hazel’s standard conditions, like under which circumstances "Date last matched" and the like are bound to change and which scope they have, i.e. does "matched" mean "by this very rule" or "by this set of rules for folder X" and so on. This would spare me a few trial-and-error runs :)

Re: Run multiple rules per item even if some don’t fail

PostPosted: Mon Apr 26, 2010 8:50 am
by Mr_Noodle
Did you check the in-app help? As for date last matched, it's the last time any rule matched and the actions executed on the file. I guess it would be by that ruleset since if you had Hazel monitoring in an overlapped fashion, the two different sets wouldn't know about eachother.

Re: Run multiple rules per item even if some don’t fail

PostPosted: Tue Apr 27, 2010 4:21 pm
by Gnashing Teeth
Mr_Noodle wrote:I have to say that I'm boggled by your statement. I do not recall the subfolder functionality changing in such a way as to break old behavior.


I have no time right now to give an example about subfolders, but here is yet another change that broke an old rule set for me (a rule set I don't use very often, but depend on every few months):

Previously, embedded scripts (e.g. Python) could have shebang lines; in the latest version, this is apparently not possible. I base this on trying to run the old set, which then bombed out at the point the embedded script was to run. Once I removed the shebang, it worked perfectly. The only reason I even guessed that removing the shebang might help was that I browsed the forums and saw a couple of script examples for Python that were basically headless, i.e. no shebang.

Re: Run multiple rules per item even if some don’t fail

PostPosted: Wed Apr 28, 2010 12:39 pm
by Mr_Noodle
Well, you brought up something breaking with subfolders and I still don't know what you are talking about.

As for the scripting, are you referring to the embedded scripts? It was changed such that you had to specify which interpreter to use in the field above the script area. I didn't think it would bomb. Did you send a bug report then?

Re: Run multiple rules per item even if some don’t fail

PostPosted: Fri Apr 30, 2010 9:21 am
by Gnashing Teeth
Mr_Noodle wrote:As for the scripting, are you referring to the embedded scripts? It was changed such that you had to specify which interpreter to use in the field above the script area. I didn't think it would bomb. Did you send a bug report then?


Some points:

1) Yes, the embedded scripts now bomb if you use a shebang line in the script. No, I didn't send a bug report. I only did this a few days ago and I am in the middle of a thousand other things far more urgent in my life.

2) As for subfolders - I no longer have whichever previous version installed it was that worked the old way I was doing it. So I can't go back and recreate precisely how it was vs. how it must be done now. However I can tell you that one thing changed for sure was the order in which I had to tell Hazel to "run rules on folder contents." I had to use trial and error to find out the new way of doing things.

3) As for rewriting your doco for you, pay me and I'll do it, but otherwise, again, I simply don't have the time. It is work to do that sort of thing right - I used to be a technical writer documenting B2B software, so I know of what I speak.

4) I do understand the importance of bug reports & system logs etc. if developers are to do anything about problems like this - they need users' help. However, it takes time out of users' lives - time that could be used to do real work. Not your fault, I know, but still a reality.

If you will pardon a small rant here, I have a long love-hate relationship with computers, starting with DOS, moving on to Windows and then Linux, and now with OS X. The more I use them the more I think apps like Hazel are in a twisted way more of a curse than a blessing. Naive users who do not bother to install this kind of customization actually have a far better signal-to-noise ratio compared to "power users" in terms of work done vs. time wasted trying to coax layers and layers of software into behaving themselves.

But again this is not your fault, just a problem with the way our lives are headed in relation to technology. I am a writer and at this point I pine for the days of typewriters. When they broke, they broke; when they got fixed, they stayed fixed for a long time. And there were no $*!_# updates or version upgrades.

Re: Run multiple rules per item even if some don’t fail

PostPosted: Fri Apr 30, 2010 11:59 am
by Mr_Noodle
It appears to me you are more concerned with venting your frustrations than actually trying to help with anything. If you have a problem, be prepared to back it up with details. If you don't have the time, then maybe you should hold off until you do. Apparently you have the time to rant which helps no one.

Also, I didn't ask you to rewrite the docs. You made the statement that they were lacking but you do not say how. Please stop making this more dramatic than it needs to be. It is unproductive and doesn't make you very credible (despite whatever expertise you may cite).

When you have the time and energy to describe the problems you are experiencing, then I would be happy to hear them so I can address them. But until then, please leave the insinuations to yourself.

Re: Run multiple rules per item even if some don’t fail

PostPosted: Fri Apr 30, 2010 12:14 pm
by Gnashing Teeth
Sorry to have p_____ you off - not my intent. I admire your work, despite my kvetches And I admire that you keep the forums open even to folks like me who express dissenting opinions and now and then rant.