How can I make Finder comments added in DT show up in Finder get info box?

(Context: DEVONthink 3.8 on Intel macOS 10.14.6.)

I gather from discussions such as this one that if a Finder comment is added to a file in DEVONthink, that comment is not actually written to the file attributes and the Finder will not show the comment unless the file in question is exported.

Is there any way to force DT to update the Finder comment of a file on demand without exporting the file? For example, if I have a markdown file and I want to write something into the Finder comment, and then read the file comment from an external application, is there a way to do it?

Only the Finder comments of indexed items are immediately updated.

I guess one could script it. The Finder suite gives you access to the File object which has a comment property. So something like

const dtApp = Application("DEVONthink 3");
const SEApp = Application("System Events");
const finderApp = Application("Finder");
dtApp.selectedRecords().forEach(r => {
  const path = r.path();
  const file = SEApp.aliases(path);
  const finderObj = Application('Finder').items[];
  finderObj.comment = r.comment();

I have no idea why one has to go through all these loops just to access a file in Finder by name, but it seems that that’s the way to go.
Disclaimer This code has not been tested, use at your own risk. Test with copies of the files before running it on any important documents.

Or like this:

tell application id "DNtp"
	repeat with theRecord in selected records
		set thePath to path of theRecord
		tell application "Finder" to set theComment to get comment of ((thePath as POSIX file) as alias)
	end repeat
end tell
1 Like

I’m not an AS person, but there seems to be something missing here. theComment is used only once, and I have the impression that the OP wanted to set the Finder comment to the DT comment. Whereas the script seems to be getting the Finder comment, storing it in theComment and then …
But I’m probably just no seeing the wood for the trees.

This was just a simple example how to easily use the path (in this case for reading).

1 Like

Thanks for people’s replies. I guess I was hoping the answer was more along the lines of a built-in DT action that would tell DT to sync Finder metadata to the file, as opposed to scripting the act of writing the comment explicitly.

DT seems to write this metadata when a file is exported, so clearly there’s functionality to map (some of) the metadata fields we see in the DT UI to a file [1]. It seems to be a performance optimization to avoid updating the file whenever the value is modified in DT, which is reasonable, but a way to do it on demand would be nice!

I use a folder indexed in two separate databases. As you said inserting text in Finder comment field, immediately add to Finder comments field and I can see it in Finder by “Get Info” command.
But another devonthink database that indexed this folder, doesn’t show the added comment.
I also used File > Update Indexed Items, in the latter devonthink database.

Where is the problem?

Why are you indexing the same folder in multiple databases?

I want to have access my files from other operating systems. Also I use devonthink to categorize files based on tags via smart groups in specific DBs.