Returning Values to Hazel Using hazelOutputAttributes

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

Moderator: Mr_Noodle

Hi,
Ive just discovered Hazel and think its amazing. Please forgive me, but I am very new to both Hazel and Apple script and am trying to write a very simple script (external) that returns a value (File Name) back to Hazel to be used later on when renaming the file. In this instance "New Filename.pdf. See eg code below.

Code: Select all
on hazelMatchFile(theFile, inputAttributes)
   
   return {hazelOutputAttributes:{"New Filename.pdf"}}
   
end hazelMatchFile


However this simple script throws an exception

Invalid AppleScript return value: <NSAppleEventDescriptor: { 'usrf':[ 'utxt'("hazelOutputAttributes"), [ 'utxt'("New Filename.pdf") ] ] }>.


I was wondering if there is a simple example of an external Applescript returning values which I can reference? Ive tried searching the forum to no avail.
theodrak
 
Posts: 3
Joined: Fri Jan 20, 2017 2:37 am

You are missing "hazelPassesScript" which is required for a match script (as opposed to action). Try adding that or moving the script to the action section.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks Mr_Noodle thats worked. Took me a little while but got there.

Code: Select all
on hazelMatchFile(theFile, inputAttributes)
   
   return {hazelPassesScript:true, hazelOutputAttributes:{"New Filename.pdf"}}
   
end hazelMatchFile
theodrak
 
Posts: 3
Joined: Fri Jan 20, 2017 2:37 am


Return to Support