I’m probably way over my head just with the asking, but here’s what I’m trying to do. I use DTTG during the day to leave notes using Siri that are sync’d to my DEVONthink Global Inbox. All good so far. What I’d like to do is automate having those notes consolidated into one text file, where each note name gets one line followed by its note body starting on the next line, and so on. The order doesn’t really matter.
As a bonus, I’d like that file to be appended to a specific markdown file on my hard drive. Can anyone point me in the right direction?
If I understand you correctly, you want to consolidate your notes into one markdown file in DT on the desktop?
That would be feasible with a smart rule or a simple script alone. In the latter case you select the records in the inbox and then run the script which
defines an empty string
looping over the selected records
appends the record’s title followed by a new line to the string
appends the record’s content (plaintext) to the string
finally, append the string to the content of a predefined markdown file
Something like this in JavaScript:
(() => {
let app = Application("DEVONthink 3");
let result = "";
let records = app.selectedRecords();
records.forEach(rec => {
result += `# ${rec.name()}\n`;
result += `${rec.plainText()}\n`; //append more \n to taste
})
let mdfile = app.createRecordWith({name: "MyMDFile", 'type' : "markdown"});
let p = mdfile.plainText() + result;
mdfile.plainText = p;
})()
You can run it in script editor or in DT after having copied it to its scripting folder
@chrillek, yes, that’s exactly what I’m trying to do. My coding chops are rusty, but you’ve pointed me in the right direction. I just spent a little time looking for good starting points for understanding JavaScript syntax. https://developer.mozilla.org/en-US/docs/Web/Tutorials#JavaScript_Tutorials - looks like a good start. Any other suggestions?
You’d need to define “selected texts” but DEVONthink To Go can do this via the Update Content Shortcut action.
DEVONthink currently cannot without some amount of scripting.