Move document to folder depending special Tag

Hi there,
I’m looking for a solution for automatic move a document into a folder.
I organised my database in 20 different folder. What I wan’t to realise is, that I assign manually a Tag to a document in the “Input” folder and when that is done the file should move automatically to the assigned folder:
For example: I have a document in the “Input” folder. I rename it and assign the needed Tags. One Tag is the folder name where the document should be stored. Now -normaly- I have to drop this document manually in the the assigned folder. This last step should be done automatically.
Is there someone with an idea to realise this ?


I think you could do that by using a smart rule. For example:


Edit: obviously you could change whatever needs changing. I appreciate that may not help if the tag itself has to be reflected in the folder to which it’s moved.

Edit 2: Sorry, I may have overlooked the fact that you will be using different tags linked to the name of the folder to which you want to move the item, so this may not be very helpful!


As a further thought, could you not rely upon “See also and classify”—which might soon learn to which folder items should be moved—and then automatically tag the moved item with the name of the group to which it is moved? That assumes, of course, you have not checked “Exclude Groups from Tagging” in the properties of the relevant database.

I suppose it depends on which you need to automate more: the move or the tagging.


I use a ProcessInbox applescript to assist with the renaming, tag assignment, …, folder movement
It could easily handle the movement to specific folders based on tags

One Tag is the folder name where the document should be stored.

Tags are groups (folders) themselves
It’s not clear why an additional group (folder) would be needed

As mentioned by @Stephen_C and @DTLow, you could use a smart rule that handles “on tagging” events. Then, you can use a script (embedded or external) like this one to sort the records into the appropriate groups.

Some things to note:

  • if you assign more than one tag to a record, only the first one will be considered
  • instead of using db: "...", group: "..." in the target, you could also use the groups’ UUID and modify the code accordingly. That’s largely a matter of taste.
  • If you have groups with the same name in a database, the first one will be considered as the target for the move.
function onperformsmartrule(records) {
  /* Define association between tags and databases/groups */
  var groups = { 
      "tag_A": { db: "DB1", group: "A"},
      "tag_B": { db: "DB1", group: "B"},
      "tag_C": { db: "DB1", group: "C"},
  const app = Application('DEVONthink 3');
 /* Loop over the records selected by the smart rule */
  records.forEach(r => {
   /* get the tag */
    const tag = r.tags()[0];
  /* get the target from the object defined above */
    const target = groups[tag];
    const dbName = target.db;
    const groupName =;
    const db = app.databases[dbName];
    /* Find the group with the given name in the database */
    const group =`name:${groupName} kind:group kind:!tag`, {in: db})[0];
   /* Move the record to the group */
    app.move(r, group);

1 Like

My ProcessInbox script operates on selected notes with the final processing step as

tell application id "DNtp" -----Update Note; Group, Title, Subject Date, DueDate , Tags ...
		-- Code to identify the variables --
		set theFilingGroup to get record at "/🗂Filing" in database "Devonthink"

		set theNote to move record theNote to theFilingGroup
		set name of theNote to theTitle
		set tags of theNote to tags of theNote & theTagList
		set locking of theNote to true
		if setDueDate then add custom meta data theDueDate for "taskduedate" to theNote
		set label of theNote to taskLabel
		set theLink to reference URL of theNote
		open window for record theNote with force
	end tell