folder action script - add to specific database & group


Search revealed lots of hits, in fact too many.
I’m looking for a basic script to import (scanned) pdf files into a specific database (scans) and into a specific group (e.g. scanned today).

I’m looking for two ways to do this:

  • folder action script
  • a script triggered by a hazel rule (embedded script in hazel)

Any pointer to working solutions extremely appreciated!



Thanks a lot, I’m looking into this.
But I don’t see where the database to be selected is set?
Am I overlooking or is it not in this script?

  1. I did the test, the script opens the sorter and lets me choose the DB.
    I’d like to hardcode the DB name, is that possible?

Something strange is happening with the group as wel: I’m working on a newly created and empty DB to which I have added a single group “to be sorted”. From this group I have copied the Item Link. (double checked, two times the same result with paste to textile)
2. The file does get imported, but it will not go into the UUID specified group?
Also the count of all but the smart group “All PDF Documents” remains at 0.
If the file is not in the Inbox, and not in the UUID group, shouldn’t it be at least elsewhere (apart from the smart folder)?

Thanks for helping out,


I find this in the script database

open database v : Open an existing DEVONthink Pro database. To close a database, use the standard "close" command.
open database text : POSIX file path of database.
→ database


This is too complicated for you, I think. You’ll have to find another reader who can explain it.

:question: :question:

Let me try to dissect:
The first part of the script:

tell application "Finder"
end tell

Is it here (the POSX path of theFile as string) that I have to replace string with the path of my DB?


I have an example of a hazel rule to import to a nominated Database/Folder that you can view here

Hope that gives you some ideas with your process.


Iain, thx for posting.
I’m travelling now.
Will test when back home.

Kind regards,


It’s here

For future readers – the first script listed in the linked page appears, at first blush, to be locating a record in a database and then re-importing it to DEVONthink. That’s actually not what the script does. It imports “theFile”, which comes from Hazel, into a group location that’s assigned to the variable “Devonthink”. It is not importing to the application DEVONthink.