I am using TextEdit and need the document to save as a .rtf, but when I am copying and pasting the data over, since there are small images and thumbnails, it will always save as .rtfd.

I am currently going through the process of doing this manually, but when dealing with 50+ documents, going into the Get Info area, setting the proper extension, then saving that file again takes time. I do not need the images to be there, but going through and removing manually is also not a good option.

I am currently trying to learn AppleScript and using Script Editor, but wanted to see if in the meantime anyone had any ideas here or have a script that does this?

  • 1
    IMO You're going about this the wrong way. A .rtfd file is actually a folder containing a file named TXT.rtf and any images that were included. I'd simply copy the TXT.rtf files out of their respective .rtfd, while renaming them in the process. Assuming all the .rtfd files are in the same folder, then in Terminal change directory to the location of the .rtfd files, i.e. cd /path/to/.rtfd_files and then use the following compound command: for d in *.rtfd; do cp -nv "${d}/TXT.rtf" "${d%.*}.rtf"; done – user3439894 Mar 23 '20 at 20:48
  • this is great information, thank you. im doing this for work, and I am in no way script or terminal savvy. I attempted to use terminal with these codes, but I am not sure exactly how. If you have time, if you could explain further how to do this, it would be great. Sorry to be a pain and thanks again. – Mari Velez Mar 24 '20 at 22:06

The @user3439894 comment provides a better solution but since this is tagged as applescript, here is an applescript answer.

Will prompt user to choose one or more rtfd, copy them to the desktop, turn them into actual folders, extract each one's text/rtf component to the desktop, and trash the unwanted bits. I don't know how you actually get the target files so I went with 'choose' and stuck to using the desktop as the workplace.

use scripting additions
-- Choose one or more rtfd
set aFilList to {}
set aFilList to (choose file with multiple selections allowed)
tell application "Finder"

    repeat with aFil in aFilList

        -- copy rtfd to desktop; collect name information       
        set dFil to duplicate aFil to (path to desktop folder)
        set {adNam, ddNam, dwXt} to {displayed name of aFil, displayed name of dFil, ".rtf"}
        --> {"filename", "filename 2", ".rtf"}, or {"filename", "filename copy", ".rtf"}

        -- Remove 'd' from extension to reveal as type:folder
        set name of dFil to ddNam & dwXt
        set dFil to ((path to desktop) & ddNam & dwXt as text)

        -- Move rtf to desktop and rename; trash intermediary files
        move file "TXT.rtf" of alias dFil to (path to desktop) with replacing
        set oFil to (path to desktop) & "TXT.rtf" as text
        set name of alias oFil to (adNam & dwXt)
        delete aFil
        delete dFil

    end repeat
end tell

For a single document, unless there's formatting you want to preserve, the easiest way is to first save it as a plan text document, then re-save it as an RTF. Or first paste the selection into BBEdit then Select All, Copy, and Paste into TextEdit.

If there is formatting you want to save, and there are only a few icons or other objects, just delete them and then save as RTF.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .