Created
August 2, 2013 10:34
-
-
Save oiva/6138972 to your computer and use it in GitHub Desktop.
Automator service for running PDFs through ABBYY FineReader Sprint. Saves results from OCR as .txt with same filename as the PDF.
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
on do_menu(app_name, menu_name, menu_item) | |
try | |
-- bring the target application to the front | |
tell application app_name | |
activate | |
end tell | |
tell application "System Events" | |
tell process app_name | |
tell menu bar 1 | |
tell menu bar item menu_name | |
tell menu menu_name | |
click menu item menu_item | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
return true | |
on error error_message | |
return false | |
end try | |
end do_menu | |
on run {input, parameters} | |
tell application "TextEdit" to quit | |
repeat with i in input | |
tell application "ABBYY FineReader Sprint 8.0" | |
activate | |
end tell | |
do_menu("ABBYY FineReader Sprint 8.0", "File", "Close") | |
tell application "System Events" | |
tell process "ABBYY FineReader Sprint 8.0" | |
set posixpath to POSIX path of i | |
set default_location to "~/Dropbox/inbox" | |
click menu item "Convert to Text Document" of menu 1 of menu bar item "File" of menu bar 1 | |
keystroke "g" using {shift down, command down} | |
delay 1 | |
keystroke posixpath | |
delay 1 | |
keystroke return | |
delay 1 | |
keystroke return | |
delay 5 | |
repeat until exists window 2 | |
delay 1 | |
end repeat | |
click button "Save" of window 1 | |
end tell | |
end tell | |
repeat until application "TextEdit" is running | |
delay 1 | |
end repeat | |
do_menu("TextEdit", "Format", "Make Plain Text") | |
tell application "System Events" | |
tell process "TextEdit" | |
tell window 1 | |
if exists sheet 1 then | |
tell sheet 1 | |
click button "ok" | |
end tell | |
end if | |
end tell | |
end tell | |
end tell | |
do_menu("TextEdit", "File", "Save") | |
do_menu("TextEdit", "TextEdit", "Quit TextEdit") | |
end repeat | |
return input | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment