Summarise (summarize) highlights with smart rule

Forgive me if this is a stupid question…

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.

Thanks very much

1 Like

There are no stupid questions unless someone is being willfully ignorant or trolling :slight_smile:

There isn’t a Summarize smart rule action, so the only option would be an Execute Script action.

Also, you haven’t defined what the trigger would be.

Thanks for the response, @BLUEFROG.

So here’s the issue I’m dealing with.

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.

Thanks again.

The smart rule and the script could look like this:

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);

You’re The Man, man! (The addressed Christian is The Man too, of course. So you’re The Men! If that does not sound un-woke.)

2 Likes

Thanks to everyone for the replies. I have managed to arrange this, with thanks to @cgrunenberg script.

I’m grateful to you all.

1 Like

This is excellent!

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?

Thanks

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
1 Like

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)

E.g. like this (assuming that the database is opened):

set theLocation to get record at "/articles/obsidian indexed" in (database named "medicine")

Thank you for such a quick response. Will try this today.

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.

There is no summarize to PDF.

Apologies I now see is just markdown, plain text, or rtf.

What is the rtf syntax? Thanks

No worries.

I now see is just markdown, plain text, or rtf.

Where are you seeing plain text supported? The Summarize Highlights command supports Markdown, rich text, or a sheet.

Summarizing to a rich text file is done via to rich, e.g,…

set theSummary to summarize highlights of records {theRecord} to rich in theLocation

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.

Nope. Not an option as plain text doesn’t support links so there’s no ability to jump back to the original file :slight_smile:

1 Like