Passing Custom Text attributes to a AppleScript action

I would like Hazel to examine the content of a document and figure out if it individually contains certain words. Then for each word it contains build a comma separated list of those (found) words so I can append it to a file name.
So if my list of words is Dog, Cat, Bird, and Ant - then I am looking for something like:
I was really hoping the new Custom List functionality would help with this but although it finds multiple words it only returns the first found word to the actions area. (Unless I am doing something wrong.)
So instead I am trying to use a set of custom text attributes:
…and want to pass them to a Run AppleScript action. But this is where I have hit a problem. I know the the matching is working because I have used a preview file (i.e. Test file has Dog and Bird in its contents) and I can successfully use the Custom Text attributes in other Hazel actions. e.g. Rename will add “Dog” because it was found but not add “Cat” because it wasn’t found.
But if I add a Run AppleScript with an embedded script, eg:
I get a dialog that says “Here: • missing value • missing value • missing value • missing value”.
In the Edit Script screen I have used the upper right button to add all four attributes to the import list.
I can’t figure out how to extract the text of the found items (“Dog” and “Bird” in my test file) from inputAttributes.
I am really hoping I am missing something simple. Any ideas?
So if my list of words is Dog, Cat, Bird, and Ant - then I am looking for something like:
- Code: Select all
DOC CONTAINS APPEND STRING
Bird “- Bird”
Dog Cat “- Dog, Cat”
Dog Cat Ant “- Dog, Cat, Ant”
I was really hoping the new Custom List functionality would help with this but although it finds multiple words it only returns the first found word to the actions area. (Unless I am doing something wrong.)
So instead I am trying to use a set of custom text attributes:
If any of the following conditions are…
Contents contain match [ • Dog ]
Contents contain match [ • Cat ] etc
…and want to pass them to a Run AppleScript action. But this is where I have hit a problem. I know the the matching is working because I have used a preview file (i.e. Test file has Dog and Bird in its contents) and I can successfully use the Custom Text attributes in other Hazel actions. e.g. Rename will add “Dog” because it was found but not add “Cat” because it wasn’t found.
But if I add a Run AppleScript with an embedded script, eg:
- Code: Select all
set theMsg to "Here: "
repeat with anInput in inputAttributes
set theMsg to theMsg & " • " & (anInput as text)
end repeat
tell application "System Events"
display dialog theMsg
end tell
I get a dialog that says “Here: • missing value • missing value • missing value • missing value”.
In the Edit Script screen I have used the upper right button to add all four attributes to the import list.
I can’t figure out how to extract the text of the found items (“Dog” and “Bird” in my test file) from inputAttributes.
I am really hoping I am missing something simple. Any ideas?