Run a specific Rule

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

Moderator: Mr_Noodle

Run a specific Rule Fri Feb 01, 2019 5:12 pm • by IVG
So the problem that I am encountering is this - When I have a rule that says "Run Rules on Folder Contents" it runs all of the rules, but I want to be able to specify what rules run on contents - so for example if I can filter the folders by tag and then chose which rule(s) will run on that folder and its subfolders... is this an option?! because I have been scouring the forums and can't find an answer...
IVG
 
Posts: 18
Joined: Tue Jan 22, 2019 5:00 pm

Re: Run a specific Rule Sat Feb 02, 2019 7:44 am • by Robert
IVG wrote:So the problem that I am encountering is this - When I have a rule that says "Run Rules on Folder Contents" it runs all of the rules, but I want to be able to specify what rules run on contents - so for example if I can filter the folders by tag and then chose which rule(s) will run on that folder and its subfolders... is this an option?! because I have been scouring the forums and can't find an answer...


First thing that comes to my mind is using a shell script within the rules condition which checks for names in the file path. So the rule is only executed when the file is in a certain folder within the directory. If you use multiple of these scripts with an "if any", then you could have one rule at the top level which is executed within the directory in different folders.

The shell script it has to pass would be something like this:
Code: Select all
string="$1"
if [[ $string == *"legal"* ]];
then
    exit 0
else
    exit 1
fi

→ If a folder named "legal" is in the files path, then execute the rule.

Of course, if the depth of the folders is only 1 folder within the main directory this would be working with a nested condition checking the enclosing folder.

But maybe there is a more elegant way of doing this.
"Behind all the inhuman aspects of automation (...) its real possibilities appear: the genesis of a technological world in which man can finally withdraw from (...) the apparatus of his labor – in order to experiment freely with it." /Marcuse
Robert
 
Posts: 52
Joined: Sun Dec 16, 2018 8:05 am

Re: Run a specific Rule Sat Feb 02, 2019 5:28 pm • by IVG
Robert,

Thanks for the reply and the help!

unfortunately this does not correct the issue that I have - because if I put this script as a condition - then the only action would be "run rules on folder contents" - then what will happen is ALL the rules that I have will be run... but I need only one out of many rules to run.

The idea behind this, is as follows:

I want to auto tag all files in my desktop so if files are 1 or 2 or 3 levels deep or more in any folder that has the name "Legal" in it, they would get a corresponding tag... and so on. But since all these rules are run in the same folder "Desktop" i want to be able to select which rules will run upon certain conditions being satisfied...

As such I don't believe that the script would do that...

Again thank you for trying to help!
IVG
 
Posts: 18
Joined: Tue Jan 22, 2019 5:00 pm

Re: Run a specific Rule Sat Feb 02, 2019 8:22 pm • by Robert
Ah – I just recognized, that you asked the other related question here, too.
viewtopic.php?f=4&t=11571
I am not sure if that solution maybe worked so that this problem could be solved too. In case it does not here are some thoughts:
The way I use the "go to subfolder rule" is, that I have it one time as a separate rule within my overall rules of the main directory (in your case the desktop). Like this:
Image
That subfolder rule will ONLY contain:
if its a folder
➔ then go to subfolders

Hazel will then check all the other rules, so the tag-rules I have next to the "go-into-subfolders" rule, within all the subfolders of the main directory.
What I am now suggesting is, that you do not change the way hazel is going into the folders, but when it is executing the other rules f.e. the tagging. So if you have a condition within the tag rules like: look for the file-path and check if it contains a certain name, then the rule will only tag those files of the whole subdirectory where a certain name is in its file path. That way, even though the "go into subfolders" rule applies to all folders, the tagging only happens in certain folders within the desktop. So for each tag you have to set a certain condition where it should tag.
If you then combine these with a nested "if any" condition you can tweak every "tag" rule to be executed in more then one folder, but not in all folders.

That would then look a bit like this:
Image

I am not sure if that helps, but for me your problem seems to be solvable with hazel...
"Behind all the inhuman aspects of automation (...) its real possibilities appear: the genesis of a technological world in which man can finally withdraw from (...) the apparatus of his labor – in order to experiment freely with it." /Marcuse
Robert
 
Posts: 52
Joined: Sun Dec 16, 2018 8:05 am

Re: Run a specific Rule Mon Feb 04, 2019 11:48 am • by Mr_Noodle
Can you provide more details on what rules you want to run on the files within?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Run a specific Rule Mon Feb 04, 2019 4:39 pm • by IVG
I was working on rules that would add tags based on certain parameters... and with Robert's help I was able to figure out a solution - where I set a limit by certain text contained in the files path... so thats all done.

That being said I have a new problem now - Hazel agent keeps running non stop - and I am wandering if it is connected to the "continue running rules" setting - would it cause such behavior? because it is taking up resources... i have many rules such as this:Image

and then the standard subfolders rule (kind is folder > run rules on contents)
IVG
 
Posts: 18
Joined: Tue Jan 22, 2019 5:00 pm

Re: Run a specific Rule Tue Feb 05, 2019 11:48 am • by Mr_Noodle
Can you post/email an excerpt of the logs?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron