AppleScript to Get Open TextEdit RTF or RTFD File Properties & Copy to Clipboard?

A TextEdit RTD or RTFD document will save various document properties that you access and edit by selecting:

File > Show Properties >

Is is possible to retrieve these properties on a currently open document via AppleScript and place them in the clipboard?

I am interested in storing some text in the Comments and later being able to copy it to the clipboard without having to manually open the properties window, selecting the text and copying it.

I don’t see any way to get these from the TextEdit RTF document per se. However, they do get mirrored to Spotlight so you can get them from there. For example, I populated the 7 fields with Blibble{1…7} and this is what I see:

% mdls test.rtf
…
kMDItemAuthors                     = (
    Blibble1
)
kMDItemComment                     = "Blibble7"
…
kMDItemCopyright                   = "Blibble3"
…
kMDItemKeywords                    = (
    Blibble6
)
…
kMDItemOrganizations               = (
    Blibble2
)
…
kMDItemSubject                     = "Blibble5"
kMDItemTitle                       = "Blibble4"
…

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

AppleScript to Get Open TextEdit RTF or RTFD File Properties & Copy to Clipboard?
 
 
Q