Page 1 of 1

Matching multiple extensions

PostPosted: Wed Aug 03, 2011 11:50 am
by SnakeZZ
Hi!

Would like to match a list of extensions for Hazel to work on, e.g. I want to match .pdf, .doc and .txt and do (something) with it,
in addition to the fact that the rule should only work if another condition matches.
In classical programming I would use
Code: Select all
(exp1 OR exp2) AND exp3

I can't find an option to insert a subcondition, nor have I found out how to write an OR in the pattern matching.

Is this even possible? How?

Best regards,

SnakeZZ

Re: Matching multiple extensions

PostPosted: Wed Aug 03, 2011 1:46 pm
by Mr_Noodle
It's not possible in the current version. Version 3 has support for subconditions (check the beta forums for a screenshot). Right now, you will have to do it via multiple rules.

Re: Matching multiple extensions

PostPosted: Fri Aug 05, 2011 2:23 am
by justinkthornton
There is a two step process to do this you could use as a stop gap till v3 comes out.

Set the first rule to "If any..." instead of "if all...."

Then create the desired conditions.

If extension is .pdf
If extension is .doc
If extension is .txt
Then do the following
set color label to green

Second rule

Use "if all" this time.
Color label is green --this will identify all 3 file types
--add the condition you want to use to identify the files. Like:
Contents contain macro economics 101
Then
--again what you want
Move file to ...

So this should result in only processing the files, regardless of which of the three they are, that meet that extra condition.

One thing you need to remember hazel seems to work it a top down fashion (mr_noodle can you confirm?) so I have found that in some cases it matters in what order you put things in. I know this is true with the different items in a rule and I believe it is also true with a list of rules themselves. So I like to order them in they order I want them to happen.

Also color labels and non dictionary keywords in the comment field (like x2b$) can be used as a way to pass files from one rule to the next. This can be a great way to do very complex and useful things with hazel.


SnakeZZ wrote:Hi!

Would like to match a list of extensions for Hazel to work on, e.g. I want to match .pdf, .doc and .txt and do (something) with it,
in addition to the fact that the rule should only work if another condition matches.
In classical programming I would use
Code: Select all
(exp1 OR exp2) AND exp3

I can't find an option to insert a subcondition, nor have I found out how to write an OR in the pattern matching.

Is this even possible? How?

Best regards,

SnakeZZ