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?
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.
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)
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.
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 . 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.