export notes as RTF from Skim?

Ideally, Skim would export all my annotations as an RTF whenever I save the target PDF, so that the new notes file is saved in the same folder as the PDF, and also replaces its older version. Right now I only know how to do this manually in Skim. (And yes, I’m aware of the automatic Skim notes backup option in the preferences, but I would really prefer my annotations in RTF form, partly so that they will be manipulatable as indexed files in DEVONthink).

Could anyone help me with this?

Hi, smac26. Welcome to MacScripter.

I have a copy of Skim, but don’t actually use it, so I’m not an expert with it. The following assumes that the document you want to save is the front one and that a file for it already exists on the disk. It resaves the document in that file and saves the notes as an RTF file in the same folder:

tell application "Skim"
	set docPath to path of front document
	set notesPath to text 1 thru -5 of docPath & " (notes).rtf"

	save front document
	save front document in notesPath as "Notes as RTF"
end tell

It’s possible for a script to use a “Save as.” dialog as well. Let me know if you need that.

thanks!