I suspect that what I want to do is a lot easier than I’m finding it to be, so any pointers to The Obvious would be most appreciated.
For the last few years I had been using a DevonThink database full of plain text items as the source of content for some email automation macros I wrote in Keyboard Maestro. That was working great, until DT changed the location of where files were kept on the filesystem – likely a part of the improved CloudKit synchronisation. I’m sure that what I was doing in the past was Wrong anyway, so, I’d like to learn how to do it Right.
I’ve read through both the KM and DT forums and haven’t found any recent articles that seemed to cover this trivial need, so apologies if I’m just missing it.
My goal: I want to grab the (always plain text) content from a DevonThink item in Keyboard Maestro and paste it in to an email. I have around 100 macros in KM, each of which would need to get the contents of a specific DevonThink item unique for that macro (yes, this was a pain to set up, but, once done, it’s done).
My approach: Until the most recent DT, I did this by using KM to “Read File to Named Clipboard” and specified (for each macro) the exact location on my macOS machine of the text content of the DT item. I would then Paste from that named clipboard, and I was good to go.
Why it “broke” for me: (Again, I am sure I was never doing this the right way) With a recent upgrade, the location of the files on the filesystem seemingly moved to a /.dtbase2/Files.noindex/txt//NameOfFile.txt location. Since there are no more than about 5 files per I realised that I probably shouldn’t count on this value being static. There’s also a likely bug with iOS Shortcuts.app such that finding DT items is now almost impossible, as the Shortcuts app seems to have a hard time searching for items using its native searching capability. (I was able to work around this and solve the problem more intelligently by using the new DT To Go shortcut items to Get the item with x-devonthink-item UUID links, I think, but, this is still work in progress. I have similar automation that I need to build to work with Preside on iOS that used to work fine, but, broke with the new DevonThink ToGo).
I tried to tell Keyboard Maestro to get the content of a DevonThink Item URL, but, that definitely did not work, so, my guess is that this will require some Apple Script if I’m going to do this.
Again, all I want to do is grab a DT Item and put it on a named clipboard, which really boils down to the right/best way to just grab the contents of a plain text DevonThink item in general.
If there’s a cunning way to do this with KM such that I can just point to the “link” of an item in DevonThink, that’d be great, but, if this requires AppleScript, then, if someone has an example they can point to of how to do what must be insanely easy, I’d appreciate it.