Script Request: Save UUID to Spotlight Comment

Hi there,

I am using Devonthink mainly in combination with Markdown notes. I reference other documents that are in my database a lot. The syntax is pretty easy and with a little help from my friend Keyboardmaestro it’s a breeze.


[Very interesting document](x-devonthink-item://359681BA-B92F-46E5-8A53-A7EF91D5FF30)

However, I am pretty concerned with how my notes will be still useful in a distant future where Devonthink won’t be accessible.
So I was thinking of saving the UUID to the Spotlight comment field. So in the worst case scenario I can still search for the file I was referring to.

I came up with a solution of doing it with Keyboardmaestro. I use the “Copy Item Link” and “Show Info” Menu to past the Link into the comment field.
However, this approach is very slow and might be prone to errors. It also lacks
simplicity.

Is there any easier way of doing it with script of automator?

Thanks for your help

This script copies the UUID to the comment but only the Spotlight comment of external/indexed files is immediately updated:


tell application "DEVONthink Pro"
	set theSelection to the selection
	repeat with theRecord in theSelection
		set the comment of theRecord to uuid of theRecord
	end repeat
end tell

See also, for example:

Thanks a lot! Works like a Charm.

tell application "DEVONthink Pro"
	set theSelection to the selection
	repeat with theRecord in theSelection
		set the comment of theRecord to "x-devonthink-item://" & uuid of theRecord
	end repeat
end tell

I added the “x-devonthink-item://” prefix.