Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
Forked from prenagha/pdfpenocr.scpt
Created May 28, 2014 18:09
Show Gist options
  • Save bryanwillis/ae21a17b0fa7846fb521 to your computer and use it in GitHub Desktop.
Save bryanwillis/ae21a17b0fa7846fb521 to your computer and use it in GitHub Desktop.
--
-- 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