Export highlighted text from multiple RTFs?

I have about 300 RTF docs that I have imported into Devonthink. In each file, there is at least one passage (sometimes more) that has been highlighted. At a minimum, I would like DTP to scan these RTF docs and export the highlighted text. Even better, it should include x number of preceding and following words. If I had everything I wanted, it would also append the filename somewhere before or after each quote.

I understand this may not be something that falls within the scope of DTP. If so, pointers to a third-party app (or perhaps Automator?) are welcome, especially if it can handle this sort of batch processing.

Thanks in advance.

EDIT: The highlighted text in most cases has also been added to the “Comment” field in “Document Properties,” so simply exporting this field would be a start.

There is a script in the Support Assistant that will “Merge Highlights” from RTF files into a new RTF file. (Help > Support Assistant > Install Extras > Scripts > Merge Highlights (2)) There is also a script at Scripts > Comments > Assemble that will merge Spotlight comments into an RTF file. Both scripts operate on the selected records. Select your RTF files and run one or the other script, then edit the result to tidy it up.

The script to merge highlights does not have your particular requirements, but you could customize the script if you feel a code coming on. :slight_smile:

That is fantastic! Many thanks. :slight_smile: