Page 1 of 1

Capturing patterns in a nested "OR" condition?

PostPosted: Sun Dec 08, 2019 7:55 pm
by felciano
Hi --

I'm trying to instrument Hazel to rename PDFs based on their contents. In particular, I would like to match a collection of documents that only vary by a few meaningful variables that I'd like to capture and include in the filename.

An example would be PDFs for car insurance statements for a multi-car household, where each car has its own insurance. I'd like to capture the name of the car (e.g. "2001 Toyota Prius" or "2013 Honda CRV") and include that in the filename. Since only one of these would occur in a given PDF, I've used a nested condition with an "If any" clause:

Image

My assumption was that the new filename would contain either "Prius" or "CRV", because only one of the two variables (Model1 and Model2) would match and have a value. Instead, all the new filenames contain "PriusCRV":

Image

The XXX and YYY above reflect different account numbers for the statements, so the matching is occurring correctly. I expect the "PriusCRV" issue is because Hazel is matching many files and the variable names persist across the matches.

Is there a better way to do this, preferably in an extensible way so that additional nested conditions could be added to capture other matches?

Thanks in advance,

Ramon

Re: Capturing patterns in a nested "OR" condition?

PostPosted: Mon Dec 09, 2019 12:18 pm
by Mr_Noodle
The matching shouldn't extend beyond that rule. Try using the preview function to view what values the custom attributes have.

Re: Capturing patterns in a nested "OR" condition?

PostPosted: Tue Dec 10, 2019 12:42 am
by felciano
Yup that did it. Turns out there were multiple matches in the document. A simple increase in pattern specificity fixed it.

Thanks for the quick response!

Ramon