Copying tags of source document when creating an annotation

I want my annotations on documents to have the same tags as the original document. For example, if I’m creating an annotation on a PDF paper that has the tag “project X”, I’d like my annotation file to get tagged with “project X” too. I filed a request with the DEVONthink developers to make this an automatic behavior, but here is a solution to doing it using Smart Rules and a short AppleScript action. It’s pretty darn simple.

  1. Create a global smart rule (mine is called “auto-copy doc tags”)
  2. Set the rule to search in your annotations group.
  3. Set the conditions and actions thus:
  4. Use this as the embedded script:
on performSmartRule(record_list)
	tell application id "DNtp"
		repeat with _record in record_list
			repeat with _incoming in incoming references of _record
				set tags of _record to tags of _incoming
			end repeat
		end repeat
	end tell
end performSmartRule

That’s all. (Note: this only works in DEVONthink 3.6 or above, when incoming references was added to the AppleScript facility.)

1 Like

Thanks for posting this
I’m curious about the user case for copying the tags to the annotation record
Your post identified a project id tag but I’m not seeing the need
In fact, I’d find it confusing in a filter on the tag to see the note listed twice

As you may know, annotations are sent to a designated group by DEVONthink, and that group is (unless the user does something to change it) separate from the group in which the annotated item lives. Thus, when viewing this group, you only see the annotation documents, not the originals. Speaking just for me and my brain, when I’m looking at the listing of annotation documents in that group, it makes sense for me to see the same tags as the things being annotated.

In my specific use, I annotate PDFs of academic articles, and use tags to indicate the subjects of the papers and projects they’re related to. It’s almost useless for me to see just a list of annotation documents, because they’re all markdown files and the document titles are rarely indicative of how I catagorize and use them.

The duplicates can be easily excluded in searches and smart groups, so I’ve never found it to be an issue. (For one thing, the annotations created by DT all have names ending in “(Annotation)”, but because they are in a specific group, that’s another way to distinguish them from the original/annotated documents.)

1 Like