Page 1 of 1

Devonthink Script Error

PostPosted: Fri Dec 31, 2021 8:57 am
by snpower
Hi,

I have created a basic rule to rename a file, then execute the Devothink Pro script, "Import, OCR, and delete".

This results in a file rename, and an error as seen in the Hazel log entry below:

2021-12-31 07:42:54.180 hazelworker[75290] [Error] AppleScript failed: Error executing AppleScript on file /Users/stephenpower/Documents/PDF Processing/OCR/2021-12-31 2021-12-31 2021-12-31 2021-12-31 1.pdf.
2021-12-31 07:42:54.180 hazelworker[75290] OSAScript error: {
OSAScriptErrorNumberKey = "-1708";
}
It is also renaming the file multiple times ??

https://imgur.com/a/0JzjhW0

Re: Devonthink Script Error

PostPosted: Fri Dec 31, 2021 10:10 am
by Mr_Noodle
Can you post the script?

Re: Devonthink Script Error

PostPosted: Fri Dec 31, 2021 1:38 pm
by snpower
Mr_Noodle wrote:Can you post the script?


Code: Select all
-- DEVONthink - Import, OCR & Delete.applescript
-- Created by Christian Grunenberg on Fri Jun 18 2010.
-- Copyright (c) 2010-2017. All rights reserved.

on adding folder items to this_folder after receiving added_items
   try
      if (count of added_items) is greater than 0 then
         tell application id "DNtp" to launch
         repeat with theItem in added_items
            set thePath to theItem as text
            if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
               set lastFileSize to 0
               set currentFileSize to 1
               repeat while lastFileSize ≠ currentFileSize
                  delay 0.5
                  set lastFileSize to currentFileSize
                  set currentFileSize to size of (info for theItem)
               end repeat
               
               try
                  tell application id "DNtp"
                     set theRecord to ocr file thePath to incoming group
                     if exists theRecord then tell application "Finder" to delete theItem
                  end tell
               end try
            end if
         end repeat
      end if
   end try
end adding folder items to

Re: Devonthink Script Error

PostPosted: Mon Jan 03, 2022 10:06 am
by Mr_Noodle
Check the manual on AppleScript. You need to use a specific handler with Hazel.