I am trying to write an Applescript to capture text to a file. By saving the file to a folder with a folder action to add to an EF library, I can save the text to a file with my choice of name, the EF library I want it to be added to, and have a copy of the file to take home to add to EF libraries on my other computer. I have a script that works, but it saves the text as pure ASCII. What is the trick to getting RTF text? My script:
set theText to the clipboard
set theTitle to the first paragraph of theText
set AppleScript's text item delimiters to " "
set wordCount to number of text items in theText
if wordCount > 5 then set wordCount to 5
set theTitle to text items 1 thru wordCount of theText as string
set theTitle to (change "," into "" in theTitle)
set theTitle to (change "'" into "" in theTitle)
set theTitle to (change "." into "" in theTitle)
set theTitle to (change "?" into "" in theTitle)
display dialog "Enter a name for file:" default answer theTitle
set theTitle to the text returned of the result
set thePath to "Documents:EF Miscellaneous Folder Action"
set theUserFolder to (path to home folder as text)
set thePath to theUserFolder & thePath & ":" & theTitle & ".rtfd"
set NewFile to open for access file thePath with write permission
write theText to NewFile
close access NewFile