Can I trigger the summarise highlights tool from the menu as consequence of a smart rule? I want to direct a smart rule to a particular folder and undertake this as an automation, but I can’t figure out how to trigger it as an action in smart rules.
I have a DT Group within a database containing a number of PDFs. Some are highlighted, some aren’t.
Those that are highlighted, I would like to extract the highlights into a markdown document which would, in effect, act as a summary document.
I was thinking I could highlight a pdf and then tag it with a specific tag (i.e. extract). A smart rule could then extract from all pdfs with that tag. I’d probably have to include in the smart rule to remove the tag, otherwise it would loop ad infinitum.
Then a second rule (or the same, I’d have to test) places the newly created document into the destination folder where I’d like to keep it.
How do I execute script action? I looked for a script for this but couldn’t find one.
on performSmartRule(theRecords)
tell application id "DNtp"
summarize highlights of records theRecords to markdown in (root of inbox)
end tell
end performSmartRule
Wouldn’t the other way around be more comfortable? I. e. add an additional condition like Tag is not Summarised and add the tag Summarised at the end of the Smart Rule. Then you would not have to add the tag manually.
Plus, if you add some highlights later it would be easier to delete a tag than to write it again to get the PDF summarised by the Smart Rule a second time. (Question to those who know: Wouldn’t a script that highlights and removes the Summarised tag at the same time be possible?)
When you are working a lot with tags to create connections between items you might find this one—wether Extract or Summarized—that serves only a technical purpose distracting. Maybe then you should create a more unobstrusive boolean custom meta data called Summarized or something like that.
Christian, would it cause you a lot of work to expand the DEVONthink script dictionary with a function to summarise to a variable and not just a file? So the highlights could at first get processed (for example getting chopped into many files) and the intermediate step of first getting a standard file that collects all highlights would not be necessary?
If for backwards compatibility summarize has to be retained unchanged, maybe something like variable [array] = highlights of record?
In the meantime, you could mimick that in just three lines of code:
const record = app.summarizeHighlights(recordsList, {to: markdown});
const summary = record.plainText();
/* do something with the summary */
app.delete(record);
Can you give suggestions on how to get the final exported highlights to another location and with a tag. Specifically I have the “highlighted” tag removed from my pdf, and my pdf is then filed away to my completed group with a status tag of done. The summarized annotation ends up in my inbox. I would like it moved to another folder and would like to tag it as well.
I do not know anything with regards to scripting, so I apologize as I’m sure this is something easy but over my head. I’m assuming there is a way to script to go to another folder (somehow changed the “root of inbox”) of the script. Also, is there a way to have the script add a tag to the file or somehow do this with the smart rule.
(Also any references for basic apple script to help with devonthink for future use would be appreciated).
Edit:
-The smart rule combines all PDFs to one markdown document with highlights summarized. Is there a way to have the smart rule run to make a new markdown document per each pdf to save me the step of manually separating this at the end?
This revision creates a summary for each item and adds the tag Summarized. However, it’s unclear where the desired location is.
property pTags : {"Summarized"}
on performSmartRule(theRecords)
tell application id "DNtp"
set theLocation to (root of inbox)
repeat with theRecord in theRecords
set theSummary to summarize highlights of records {theRecord} to markdown in theLocation
set tags of theSummary to pTags
end repeat
end tell
end performSmartRule
An example for location would be database “medicine” under group “articles” then group “obsidian indexed”. How would I phrase this ( am assuming syntax to replace the in the root of inbox)
This worked great. I have lots of ideas of how to automate my workflow now.
I have been to easily change location, tags, and nested tags. What is syntax if I wanted summarized rtf and pdf (assuming “to pdf” but not sure for rich text.
I thought in one of the scripts from another thread (may have been Reddit though) someone had plaintext in place of markdown. It’s probably my mistake.