Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
applescript folder action to have docs ocr'd by pdfpen
--
-- 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