Link to home
Start Free TrialLog in
Avatar of steveurich
steveurichFlag for United States of America

asked on

Apple script called by Hazel fails

Here is the Script courtesy of Brooks Duncan at Document Snap and MacSparky.

I have run it on about 500 files and it mostly runs OK but it has failed about 30 times. Do you think that the delay needs to be increased? Is there anywhere to look for why it failed?


tell application "PDFpenPro"
      open theFile as alias
      tell document 1
            ocr
            repeat while performing ocr
                  delay 1
            end repeat
            delay 1
            close with saving
      end tell
end tell
Avatar of Eoin OSullivan
Eoin OSullivan
Flag of Ireland image

That script is very basic and really you won't get much debug or errors .. did the failed files have anything in common?  multiple pages, large filesize?
The script has a 1 second loop while performing the OCR which checking if the OCR completed every second .. I'd suggest you increase the interval to 5 or 10 seconds at least between checks
The second delay waits 1 second after the ocr stops to close and save ... again if you increase to a slightly longer period it might avoid any issues with taking longer to save the file

If you increase the delays and re-test on the files that failed .. you should see if it improves the issue and reduces the failure rate.
Avatar of steveurich

ASKER

I set them both to 10 and have not had any errors but it is taking a long time to even process a 2 page PDF.

Not sure which timer loop is doing what.

Is the first loop telling PDFPen to do the next page?

Is the second loop waiting to save the document?

Thanks,

Steve
ASKER CERTIFIED SOLUTION
Avatar of Eoin OSullivan
Eoin OSullivan
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help.