If any, then

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

Moderator: Mr_Noodle

If any, then Sun Jan 15, 2017 10:15 pm • by alpatti
To determine a vendor's name I typically end up with

if any
contents | contains match | custom text Vendor
contents | contains match | custom text phone
contents | contains match | custom text Address
contents | contains match | custom text Acct#

Usually one of these matches, so then comes the "then". How do I set vendor name that matches one of the above?

If Hazel can't do it, I would suspect that a script could. From searching the forum it doesn't seem that Hazel can pass variables back and forth to a shell scripts. An AppleScript might work, but my AppleScript skill level novice at best. Searching the forum for AppleScript is a painful way to learn how to use an app. Can you point me to an AppleScript that might do what I want ?

On a maybe related topic, How does the action "continue matching rules" work? It doesn't seem to take any arguments and I can't create any more condition rules after that action.
alpatti
 
Posts: 12
Joined: Fri Jan 06, 2017 9:00 am

Re: If any, then Mon Jan 16, 2017 2:56 pm • by Mr_Noodle
I'm a little fuzzy on what you are asking here but if you want one custom text attribute to match one of those, then re-use the same attribute (i.e. drag it in - do not create it from scratch). The attribute will use the first match in subsequent appearances.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: If any, then Mon Jan 16, 2017 10:07 pm • by alpatti
I have bill I want to rename Vendor-Date.pdf.

If I'm lucky, the Vendor condition will match and I can rename the file.

If I'm not lucky, the Phone number will match, so I know the bill came from Vendor, but I don't want to rename the file 561-321-3434-Date.pdf. Yes I can use the Vendor condition name again, but the custom text would be a phone number which I don't want to use in the rename action.
I could write a shell script that said
if Phone=561-321-3434, then Vendor=HomeDepot
but I don't know how to pass Phone to the script and get Vendor back from the script.

It sounded like Hazel and AppleScript can communicate where variables can be passed back and forth, but I can't find any examples (related to Hazel) for this logic..
alpatti
 
Posts: 12
Joined: Fri Jan 06, 2017 9:00 am

Re: If any, then Tue Jan 17, 2017 1:08 pm • by Mr_Noodle
Search the help for details on how to use AppleScript for this. You basically can send back variables via a special record which is outlined in the help.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support