Alter applescript to reformat multiple RTF documents

I desperately need an applescript to change the font of hundreds of RTF documents from one font to another without removing bold/italics (e.g. of headings). I found this script kindly uploaded to the forum by Christian:

    tell application "DEVONthink Pro"
       try
          set theSelection to the selection
          if theSelection is {} then error "Please select some records."
          repeat with theRecord in theSelection
             set theDate to the modification date of theRecord
             set theWin to open window for record theRecord
             tell text of theWin to set {line spacing, font, size, alignment} to {1.0, "Courier New", 14.6, left}
             close theWin with saving
             set the modification date of theRecord to theDate
          end repeat
       on error errText
          display dialog errText
       end try
    end tell

But it removes bold/italic formatting. Does anyone know how to script changing just the font family of multiple rich text documents? Apologies for asking a rather particular question, but I am at a v. basic stage of applescript learning, and this is fairly urgent. I’d hope others would have use for such a script as well.

You would need to explicitly change the font name of each attribute run, taking into account variations (such as bold, black, italic, oblique, etc.).

For example (thanks to Michael Tsai and “sammy” at Eagle Filer):

tell text of front document
	set font of every attribute run whose ((font contains "Bold" or font contains "Black") and (font contains "Italic" or font contains "Oblique")) to "Helvetica-BoldOblique"
	set font of every attribute run whose ((font does not contain "Helvetica-BoldOblique") and (font contains "Bold" or font contains "Black")) to "Helvetica-Bold"
	set font of every attribute run whose ((font does not contain "Helvetica-BoldOblique") and (font contains "Italic" or font contains "Oblique")) to "Helvetica-Oblique"
	set font of every attribute run whose (font starts with "HelveticaNeue" or font does not start with "Helvetica") to "Helvetica"
end tell

Substitute font names as appropriate, or extend this model to meet the characteristics of your data.

WARNING: there is no “undo” possible if you apply this type of script to your RTF files. The change is permanent.

Brilliant, thank you!

korn, this script works only in Applescript editor. I am not able to get it working elsewhere. Have tried launching the script thought Keyboard maestro and fast scripts.

Yes, I can’t seem to get this script working again (it’s been a while since I’ve used it). Any thoughts, Korm?