Can multiple rules be applied to a file?

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

Moderator: Mr_Noodle

Can multiple rules be applied to a file? Fri May 15, 2009 12:43 pm • by jordanekay
As I see it, a file can only match up to one rule. This greatly reduces the functionality of Hazel, and so much more could be done if multiple rules could be applied to a file. Are there any plans for this functionality to be implemented in the future?
jordanekay
 
Posts: 6
Joined: Fri May 02, 2008 9:43 pm

Technically speaking, there shouldn't be anything that can't be done under one vs multiple rule matching. It's just that in the former case, you end up with more/wordier rules. What it does buy you is a much simpler set of rules to understand and debug, if need be.

Can you post what kind of rules you need to do? I usually find that what people want to do can actually be done in a straightforward way in the current scheme but for whatever reason, they misunderstand how it works. Even if it ends up being awkward or somehow undoable, it gives me a good use case for future developments.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Can multiple rules be applied to a file? Fri May 15, 2009 11:30 pm • by jordanekay
I want every file downloaded to my Downloads folder to have its file extension hidden. So I use the built-in AppleScript

Code: Select all
tell application "Finder"
set extension hidden of theFile to true
end tell


I have a rule that is applied to every file downloaded that contains this AppleScript. However, I also want certain files to also be moved to an appropriate folder based on the site they were downloaded from, so for this I need a rule that has both this AppleScript and the file-moving part. I have about six of these rules, so I need to duplicate this built-in AppleScript for each.

What should be allowed, and what's the most intuitive, would be for a file that needs to be moved to another folder, have the extension-hiding rule AND the file-moving rule be applied to that file, so I wouldn't have to duplicate the AppleScript each time. This way, each file-moving rule would just contain the command to move the file to the appropriate folder.
jordanekay
 
Posts: 6
Joined: Fri May 02, 2008 9:43 pm

One thing to try is to do it in two passes. You can have one rule to match newly added files. That rule can hide the extension and then set some flag, like set the color or set a specific comment. The rules to move the file can then check for that color or comment and move it from there.

It was a specific design decision to not allow multiple matches. It seems intuitive only because you have this case mapped out in your head. It becomes totally confusing when you have side-effects from "fall-through" that you didn't intend. Mail does that right now with rules and people forgetting to add the "Stop evaluating rules" seems to be very common from what I've seen (and I forget to do it myself a lot of the time). I understand it makes things a bit less convenient but it does prevent a lot of unnecessary errors.

Note, though, that I would consider the inverse action of the "Stop evaluating rules" which would be something like "Continue evaluating rules". I'd have to think about it a bit and can't say if/when it would go in but if this is something I'll consider. Any feedback appreciated.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support