I am using a network scanner to scan and email me PDFs of a variety of documents. What I would like to do is to come up with a script to have devonthink grab those PDFs, which again are email attachments, import them, OCR them, and then move them to a folder.
Make a script to include in a mail rule to save attachments to a folder (see sample, below)
Make a folder action in Automator that takes new items in that folder, OCRs them, and saves them to DT in the destination configured in Preferences > Import > Destination
Script – here is an example (needs modification to specify the destination folder in Finder). Modify this for your local circumstances. Save wherever you want to save it, and create a mail rule that applies to a given account and/or FROM and/or TO, or whatever suits your usage.
using terms from application "Mail"
on perform mail action with messages theMsges
(* modify the next line to include the path to your attachment's folder *)
set theAttachmentPath to (path to desktop) as text
tell application "Mail"
repeat with ThisMessage in theMsges
set Attached to mail attachments of ThisMessage
repeat with ThisAttach in Attached
set FileName to name of ThisAttach
save ThisAttach in theAttachmentPath & (FileName)
end repeat
end repeat
end tell
end perform mail action with messages
end using terms from
using terms from application "Mail"
on run
tell application "Mail" to set sel to selection
tell me to perform mail action with messages (sel)
end run
end using terms from