Page 1 of 1

Possible to get data from a script to a custom attribute?

PostPosted: Sun Jan 03, 2016 11:30 pm
by Peeja
I have a rule which OCRs scanned PDFs and puts the text into an xattr. Then I match on the contents of the xattr to decide what to do with it.

However, Hazel doesn't give me a way to natively match xattrs, so I have to use a "Passes shell script" condition. Because of that, I don't appear to have the opportunity to pull bits out into custom attributes, which means I can't (for instance) rename the file based on the xattr's contents (without resorting to
Code: Select all
mv
in a shell script, which is proving messy).

Am I missing something? Or am I stuck doing my actions in Bash if I want to use the info from the xattr?

Re: Possible to get data from a script to a custom attribute

PostPosted: Mon Jan 04, 2016 12:31 pm
by Mr_Noodle
You can try using AppleScript. Shell scripts can be called from AppleScript though the resulting script may be a bit unwieldy. Nonetheless, something to try.

Re: Possible to get data from a script to a custom attribute

PostPosted: Sat Jan 09, 2016 3:59 pm
by Peeja
I'm not sure how that helps. AppleScripts can't add custom attributes any more than shell scripts can, can they?

Re: Possible to get data from a script to a custom attribute

PostPosted: Sat Jan 09, 2016 4:03 pm
by Peeja
Oh, they can! I was looking at old posts, not the actual Help Center docs. Thanks! That'll do nicely.

Re: Possible to get data from a script to a custom attribute

PostPosted: Mon Feb 01, 2016 10:08 am
by vloryan
You got a solution for that? I am also desperately looking for a solution that allows my custom attributes to be used in a shell script. thanks!

Re: Possible to get data from a script to a custom attribute

PostPosted: Mon Feb 01, 2016 11:42 am
by Mr_Noodle
As mentioned above, only possible with AppleScript (or JavaScript). You can execute shell scripts from AppleScript so you can go that route if you absolutely need to run a shell script in some form.