OSAScriptErrorNumberKey = "-1708"

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

Moderator: Mr_Noodle

OSAScriptErrorNumberKey = "-1708" Mon May 20, 2019 3:59 pm • by chipbeaulieu
Trying to create my first Hazel Rule. The plan:

1. Watch Downloads folder for new PDF files
2. If contents match 3 different options then
3. Run AppleScript to rename the file.
4. Move the file to another folder.

Steps 1 and 2 work correctly. The log matches the file based on kind and three content strings.

Step 3 AppleScript renames files with names like December 27, 2018.pdf to 2018-12-27.pdf

According to the log, the Hazel step 3 fails with OSAScriptErrorNumberKey = "-1708".

The AppleScript has the following handler:

Code: Select all
on hazelMatchFile(theFile, inputAttributes)
   
   -- Add your logic here. Don't need the inputAttributes.
   my CheckName(theFile)
   
   -- ‘theFile’ is an alias to the file that matched.
   
   -- ‘inputAttributes’ is an AppleScript list of the values of any attributes you told Hazel to pass in.
   
   -- Be sure to return true or false (or optionally a record) to indicate whether the file passes this script.
   return true
end hazelMatchFile


The CheckName handler does the work of renaming the file. I've tested the handler manually using:
Code: Select all
(*
tell application "Finder"
   set thisFile to alias "Macintosh HD:Users:myUserName:Downloads:December 27, 2018.pdf"
   --my CheckName(thisFile)
   my hazelMatchFile(thisFile, "")
end tell
*)


Both options above work correctly when manually running the script through Script Debugger.

If anyone has ideas about what to try next, I'd appreciate it!
chipbeaulieu
 
Posts: 2
Joined: Mon May 20, 2019 3:41 pm

Re: OSAScriptErrorNumberKey = "-1708" Tue May 21, 2019 10:27 am • by Mr_Noodle
Is this script in a condition or action? If it's an action, you need to use hazelProcessFile(), not hazelMatchFile().
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: OSAScriptErrorNumberKey = "-1708" Tue May 21, 2019 10:27 am • by Mr_Noodle
Is this script in a condition or action? If it's an action, you need to use hazelProcessFile(), not hazelMatchFile().
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: OSAScriptErrorNumberKey = "-1708" Tue May 21, 2019 2:50 pm • by chipbeaulieu
It was an action! I changed the script to hazelProcessFile and everything works as expected! Thanks everyone...
chipbeaulieu
 
Posts: 2
Joined: Mon May 20, 2019 3:41 pm


Return to Support