Run Convert Keywords to Tags via Applescript

Is there a way to run Data --> Tags --> Convert Keywords to Tags on the fixed Group via an Applescript?

See e.g. Newbie with question about keywords. Please note that you have to change the id from “com.devon-technologies.thinkpro2” to “DNtp”. This is the recommended identifier for some time and compatible to all versions/editions.

Thanks for the pointer @cgrunenberg.

I had a look at the script and it seems to reinvent the wheel: DT3 already provides this function.

Isn’t there a way to tap with Appliscript into the function DT offers?

tell application id "DNtp"
	set sel to (item 1 of (selection as list))
	extract keywords from record sel with existing tags
end tell

No. But why would you like to use AppleScript for the group if the built-in functions can do this too?

I just want to kick off the procedure Convert Keywords to Tags for a fixed group from an external script.


I have an external (Python) script that replaces some documents in ~/Dropbox/read/calibre-books nightly. This folderis indexed by DT3.

So at the end of the external script I would like to instruct the running DT to:

  1. Re-index the DT group pointing to ~/Dropbox/read/calibre-books.
  2. Kick off the Convert Keywords to Tags action for this group.

I hope this makes sense.

Hi Jim, thanks for the Applescript, but it doesn’t do anything for me:

I have selected the group with the indexed folder, then I run your code in Script Editor. But when I check the documents in the group they still don’t have the tags from the keywords. (I think the script only extract keywords, but does not calls the Convert Keywords to Tags function to set the tags.)

Using the Menu item “Convert Keywords to Tags” it works perfectly for all documents in the group. So how can I initiate the Convert Keywords to Tags function on the selected group from Applescript? Or is there no way to do this?

To “close” this topic, with the new SmartRule feature in DEVONthink 3.5 I could solve this issue (with the generous help of BLUEFROG) very elegantly:

1 Like