The script in this posting is deprecated. Scroll down this thread and see the updated script dated July 10, 2013 – five posts below this one
See these topics:
Script to include in a Hazel (3.x) rule to import or index files (or folders) to DEVONthink (2.x). Applies concepts developed by itaiferber and Greg Jones.
Modify the DEVONthink “tell” block:
- Obtain the filesystem path for the target database and insert it in place of leaving the quotations: for example “~/Documents/Databases/My Stuff.dtBase2”
- Enter the group path (starting at the database root – which is “/”), in place of leaving the quotations. For example “/Imports/My Hazel Docs/”
- To import, use the command line beginning “set theImport…”
- To index, use the command line beginning “set theIndex…”
- Be sure to comment out either #3 or #4 depending on the method, else you will have an undesireable result.
The script will create the group with the given path in the database. If the group already exists, the existing group will be used and a new group will not be created.
WARNING: This script has to have correctly hardcoded database and group paths. If the paths are wrong or the database and/or the group is moved, the script will fail.
-- Get file metadata from Finder.
tell application "Finder"
set _path to (the POSIX path of theFile as string)
set _name to (the name of theFile as string)
end tell
-- Lauch DEVONthink if it isn't already open.
tell application "System Events"
if not (exists process "DEVONthink Pro Office") then
tell application id "com.devon-technologies.thinkpro2" to activate
end if
end tell
-- Import the file.
tell application id "com.devon-technologies.thinkpro2"
set theDatabase to open database "<DATABASE PATH>"
set theGroup to create location "<GROUP PATH>" in theDatabase
set theImport to import _path name _name to theGroup
-- set theIndex to indicate _path to theGroup
end tell
It’s advisable to have Hazel delete items after they are imported – but do NOT have Hazel delete indexed documents