Created
December 6, 2013 16:46
-
-
Save henryroe/7828056 to your computer and use it in GitHub Desktop.
OCR all documents in a user selected folder using PDFpenPro 6 on OS X
Note: No recursion into other folders. For a recursive version, see: https://gist.github.com/henryroe/7828092
This file contains hidden or 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 in a folder | |
-- | |
set theFolder to (choose folder with prompt "Choose Folder to OCR every PDF in") | |
ocr_this_folder(theFolder) | |
on ocr_pdf(PDFfilename) | |
tell application "PDFpenPro 6" | |
open PDFfilename | |
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 tell | |
end ocr_pdf | |
on ocr_this_folder(FolderName) | |
tell application "Finder" | |
set PDFFiles to (files of folder FolderName whose name extension is "pdf") as alias list | |
end tell | |
try | |
repeat with i from 1 to number of items in PDFFiles | |
set this_item to item i of PDFFiles | |
ocr_pdf(this_item) | |
end repeat | |
on error errText | |
display dialog "OCRMe Error: " & errText | |
end try | |
end ocr_this_folder | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment