hello
i would Like some ideas about how i can use OCR to sort scaned papers.
my ideal worflow would be:
i receive a lot of papers every day : biological results, letters, …
i Will scan all these papers with s1500 and OCR them
and with an automatic script which recognize some keywords, DTPO would sort these papers to dedicated folders.
This is indeed scriptable, here’s a simple example:
-- Automatic filing based on keywords
property pKeywords : {"Test", "House"}
tell application "DEVONthink Pro"
set theSelection to the selection
repeat with theRecord in theSelection
set theText to plain text of theRecord
set didMove to false
repeat with theKeyword in pKeywords
if theText contains theKeyword then
set theDatabase to database of theRecord
set theGroup to create location ("/" & theKeyword) in theDatabase
if didMove is false then
move record theRecord to theGroup
set didMove to true
else
replicate record theRecord to theGroup
end if
end if
end repeat
end repeat
end tell
And a revised script which is tagging the selected items instead of moving/replicating them:
-- Automatic tagging based on keywords
property pKeywords : {"Test", "House"}
tell application "DEVONthink Pro"
set theSelection to the selection
repeat with theRecord in theSelection
set theText to plain text of theRecord
set shouldTag to false
set theTags to tags of theRecord
repeat with theKeyword in pKeywords
if theText contains theKeyword then
set theTags to theTags & theKeyword
set shouldTag to true
end if
end repeat
if shouldTag then set tags of theRecord to theTags
end repeat
end tell
another question: is it possible to attach the script to a folder in the database?
and at least with this script: moving files to folders which already and not creating new folder?
The first step is to have a look at the supported commands by dropping an application on the AppleScript editor application. The second step might be a book/tutorial but as I’ve never read one, someone else might be able to recommend a good one.
It’s possible to attacht scripts to any item (see Info panel) and opening/viewing it executes the script. But the example scripts are just using the selection and are therefore
not suitable without additional work.
You could replace the line…
set theGroup to create location ("/" & theKeyword) in theDatabase
…with:
set theGroup to parent named theKeyword in theDatabase
Best way to learn any language is to use it. Lots of scripting examples in this forum are good models and easily adapted. The macscripter.net forum is also a venerable institution on the topic with friendly participants and lots of documentation.