-
-
Save johanoloflindberg/7beab094b7bf4d6698ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- OCR all documents added to a folder | |
-- | |
on adding folder items to this_folder after receiving added_items | |
try | |
repeat with i from 1 to number of items in added_items | |
set this_item to item i of added_items | |
set appName to my getAppName() | |
tell application appName | |
activate | |
using terms from application "PDFpen" | |
open this_item | |
set theDoc to document 1 | |
if needs ocr of theDoc then | |
ocr theDoc | |
repeat while performing ocr of theDoc | |
end repeat | |
save theDoc | |
end if | |
close theDoc | |
end using terms from | |
end tell | |
end repeat | |
on error errText | |
display dialog "OCRMe Error: " & errText | |
end try | |
end adding folder items to | |
on getAppName() | |
tell application "Finder" | |
try | |
try | |
set appName to name of application file id "com.smileonmymac.PDFpen" | |
on error | |
set appName to name of application file id "com.smileonmymac.PDFpenPro" | |
end try | |
on error | |
set appName to name of application file id "com.smileonmymac.PDFPen.MacAppStore" | |
end try | |
end tell | |
return appName as string | |
end getAppName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment