Auto-Tag in DevonThink3 ? (and other questions)

Hello, I’new to DT, and really impressed by its auto-classify and search feature.
I’d like to know if it is feseable to set up an auto-tag feature, which uses DT’s Ai , in a way analogous to auto-classify?
Also, is it possible to set up a search for documents where for example “the word ‘Dirac’ occurs at least 3 times” ?


Use smart rules in 3.0 beta. You can match exact or wildcard or combination of one/more words or any other criteria and tell the rule to assign a tag for items that satisfy the rule upon some trigger or perform the check regularly. But I am not sure if counts of word can be added as criteria - please wait for the expert advice…

Thanks for the feedback, we’ll consider this for future releases. In the meantime you could also try a smart rule executing the “Assign Tags” script. This script looks for both hash tags and tags of the database in the title & text of the document.

I would like to index my Papers3 database inside DT, ans use the AI. But Auto-sort would move the files inside Papers3 database. Then Papers3 would not be able to read the database anymore. That’s why I was thinking about auto-tagging.
I’ll take a look at the smart rules, and the scripts. Thanks for your answers, ngan and cgrunenberg.

I’ve been trying to figure out how to automatically tag a load of markdown documents now that I’ve decided to use DT for a Zettelkasten. The notes that I’ve brought in have hashtags in the text (they’re treated as meta in markdown as the first line of each file is "Tags: " followed by a series of hashtags).

I’ve tried converting hashtags, but it didn’t work so I have concluded that this is about hashtags in the actual file meta, rather than in the text (as ‘pseudo-meta’ in markdown).

Having seen this thread I tried using the ‘assign tags’ script. This picked up text in the note which matched the tags I’ve created in DT, but it did not pick up the hashtags – presumably because of the hash?

I’m wondering if this needs scripting, but it’s beyond my AppleScript capabilities. The ideal would be find each of the hashtags, apply the corresponding DT tag, and create a DT tag if there is not yet a corresponding one. Am I missing something simpler?

Hashtags that are rendered in the file are detected for conversion to tags. Metadata is not rendered.

What are you using the metadata for?

This script will cull out hashtags in the Markdown metadata provided the metadata line starts with Tags: or tags:

set ot to AppleScript's text item delimiters
tell application id "DNtp"
	repeat with thisRecord in (selected records)
		if (type of thisRecord as string) = "markdown" then
			set src to (plain text of thisRecord)
			set AppleScript's text item delimiters to "#"
			repeat with thisLine in (paragraphs of src)
				ignoring case
					if (thisLine contains "tags:") then
						set hTags to (text items 2 thru -1 of thisLine as list)
						set tags of thisRecord to (tags of thisRecord & hTags)
						exit repeat
					end if
				end ignoring
			end repeat
			set AppleScript's text item delimiters to ot
		end if
	end repeat
end tell

That’s brilliant – works great. Thank you so much.

You’re welcome.