Convert RTFD to Doc (without losing images)

Hello!


Is it possible to convert RTFD-format files to Microsoft Word (doc) format - without losing images?


As a longtime Mac user, I have a multitude of RTF and RTFD files. I want to be able to access the contents of these files on platforms other than OS X (eg: Windows).


RTFD is not supported outside OS X. I'll qualify this by acknowleding that since RTFD files are OS X Packages, they show up in Windows as a folder containing image files and an RTF file; some people conclude that this is acceptable since, strictly speaking, its readable by windows. I disagree because its fiddly and hack-like rather than simple, recognizable and practical like a .doc file.


Given that I can open an RTFD file, copy/paste it's content (images and text) to a new blank Microsoft Word document and save it as .doc, it seems to me that I should be able to automate those steps using AppleScript or Automator.


I've Googled for a solution to this but no-one else is talking about it, with the exception of:

- the command-line 'textutil' converter, but that creates ascii files that are necessarily stripped of all images

- converting to HTML, but that creates more than a single file (an HTML file plus a folder containing the images)


Am I missing something really obvious?


Many thanks!

Peter

MacBook Air, OS X Mountain Lion (10.8.2), iMac, iPad mini

Posted on Mar 7, 2013 7:29 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 26, 2013 3:53 PM

Hi duncang!


The command-line 'textutil' app strips out images and so is useless for my purposes. As you pointed out, the solutions suggested by MrHoffman and Etresoft are incorrect.


A solution for my original post for this thread: use Apple's Pages for Mac (part of the iWork '09 Suite). I have succesfully converted thousands of RTFD files containing images into Microsoft Word (.doc) format.


If you have a lot of RTFD files to convert, then I recommend using an applescript to automate the process.


The applescript wizard Yvan Koenig (link) has very kindly provided a useful applescript for Pages '09 to automatically convert batches of RTF and RTFD files into Word or PDF. That guy knows what he's talking about and should be knighted for his efforts and kindness.


Look on his Box dot net public folder (link) for a file called 'batch_Pages2Doc.zip' (created Jan 31 2013). Here is the path to the file: / for_iWork'09 / for_Pages09 / batch_Pages2Doc.zip


- open the script in 'AppleScript Editor' on your Mac

- read the useful instructions he provides in comments within the script

- save it as an application so you can use it as a droplet onto which you can drag multiple RTFD files

- you can even edit the script using his instructions so it exports PDF as well as Doc

- it saves output to a 'wasPages_now_doc' folder on either your desktop or in your Documents folder


I'm running:

- Mac OS X 10.8.4

- iWork 2009 (retail boxed edition, not Mac App Store edition)


I hope this helps. It took me months to discover the solution to my original post.


-Peter

34 replies
Question marked as Top-ranking reply

Jul 26, 2013 3:53 PM in response to duncang

Hi duncang!


The command-line 'textutil' app strips out images and so is useless for my purposes. As you pointed out, the solutions suggested by MrHoffman and Etresoft are incorrect.


A solution for my original post for this thread: use Apple's Pages for Mac (part of the iWork '09 Suite). I have succesfully converted thousands of RTFD files containing images into Microsoft Word (.doc) format.


If you have a lot of RTFD files to convert, then I recommend using an applescript to automate the process.


The applescript wizard Yvan Koenig (link) has very kindly provided a useful applescript for Pages '09 to automatically convert batches of RTF and RTFD files into Word or PDF. That guy knows what he's talking about and should be knighted for his efforts and kindness.


Look on his Box dot net public folder (link) for a file called 'batch_Pages2Doc.zip' (created Jan 31 2013). Here is the path to the file: / for_iWork'09 / for_Pages09 / batch_Pages2Doc.zip


- open the script in 'AppleScript Editor' on your Mac

- read the useful instructions he provides in comments within the script

- save it as an application so you can use it as a droplet onto which you can drag multiple RTFD files

- you can even edit the script using his instructions so it exports PDF as well as Doc

- it saves output to a 'wasPages_now_doc' folder on either your desktop or in your Documents folder


I'm running:

- Mac OS X 10.8.4

- iWork 2009 (retail boxed edition, not Mac App Store edition)


I hope this helps. It took me months to discover the solution to my original post.


-Peter

Oct 1, 2015 5:08 AM in response to dsiegel06

The following AppleScript will use Pages '09 to convert Rich Text (RTF) and Rich Text Documents with Attachments (RTFD) files to Word .doc format. It is strictly a drag and drop application, where you can drop singular file(s)/folder(s), or mixtures of file(s)/folder(s) on it. Output MS Word .doc files will be written back to the location of the original rtf/rtfd document. There may be some content in RTF/RTFD documents that Pages cannot manage.


The AppleScript has been tested on Mavericks (10.9.5), and Yosemite (10.10.5), but not El Capitan (as of this post). It assumes that Pages '09 is located in your Applications/iWork '09 folder, which would be the case if an iWork '09 DVD install, or the installation of Pages v5 over a prior App Store purchase of Pages '09.


You do not need to know AppleScript in order to make this code into an application. It is a tested black box. You know, the kind where you put a nickel in it and a hand comes out to switch it off. You will be saving the script source, and then the Desktop application.


Installation Instructions

  1. Click on the Launchpad icon in your Dock. Click on the Other folder.
    1. For Mavericks, click once on AppleScript Editor
    2. For Yosemite, click once on Script Editor
  2. Copy and paste the AppleScript code below (not the word AppleScript Source) into either of these editors
  3. On the editor's toolbar, click the compile (hammer) icon. A successful compile begets multi-colored text.
  4. From the editor's File menu, choose Save… and from the save panel:
    1. Save As: rtf2doc
    2. Click in the Favorites sidebar — Documents
    3. File Format: Text (rtf2doc will now change to rtf2doc.applescript — a text file)
    4. Hide Extension is unchecked
    5. All other defaults remain unchanged
    6. Save
  5. From the editor's File menu, press the option key and choose Save As…
    1. Save As: rtf2doc
    2. Click in the Favorites sidebar — Desktop
    3. File Format: Application
    4. Hide Extension is checked
    5. Options: all unchecked
    6. Save
  6. Quit your AppleScript Editor


You now have a functional application on your desktop.


AppleScript Source


(*

Name: rtf2doc.applescript

Usage: Drag/drop Desktop conversion application

Input: Individual File(s) and/or folder(s) of RTF/RTFD documents

Output: Word .doc file written to input file location

Assume: Pages '09 is located in Applications/iWork '09 folder

Tested: OS X 10.9.5, OS X 10.10.5

Author: VikingOSX, Apple Support Community, Oct. 2015

Rev: 1.0

*)


use scripting additions


property allowed_extensions : {"rtf", "rtfd"}

property Pages09 : ((path to applications folder) as text) & "iWork '09:" & "Pages.app:"


-- drop target for files and folders

on open of fileObjects

set code_block to "Main" -- for error handler

try

repeat with aFile in fileObjects

tell application "Finder" to set itemProp to properties of aFile as list

-- strictly a folder here

if (item 1 of itemProp) contains «class cfol» then

tell application "Finder"

-- drill down into entire dropped folder hierarchy

set rtf_list to (every item in the entire contents of folder aFile whose name extension is in allowed_extensions) as alias list

end tell

repeat with anItem in rtf_list

process_rtf(anItem)

end repeat

-- restrict to rtf/rtfd name extensions

else if (item 5 of itemProp) is in allowed_extensions then

process_rtf(aFile as alias)

end if

end repeat

on error errmsg number errnbr

err_handler(code_block, errnbr, errmsg)

quit

end try

tell my application "Pages" to if it is running then quit

return

end open


on process_rtf(theFile)

set code_block to "process_rtf"

try

-- trim extension from filename

tell application "Finder"

if (length of ((name extension of theFile) as text) as integer) = 4 then

set wordDoc to text 1 thru -6 of (theFile as text) -- remove rtfd

else

set wordDoc to text 1 thru -4 of (theFile as text) -- remove rtf

end if

end tell

-- add new extension for output file

set wordDoc to wordDoc & "doc"

tell my application Pages09

open theFile

save front document as "Microsoft Word 97 - 2004 document" in wordDoc

close front document saving no

end tell

on error errmsg number errnbr

err_handler(code_block, errnbr, errmsg)

quit

end try

return

end process_rtf


on err_handler(location, nbr, msg)

-- dialog will self-destruct in 15 seconds

display alert "RTF to Word Application Error" message "Location: " & location & return & "[" & nbr & "]: " & msg ¬

as critical giving up after 15

tell my application Pages09 to if it is running then quit

return

end err_handler

Oct 17, 2015 9:50 AM in response to VikingOSX

The RTF/RTFD to Word DOC converter has been updated to check for the presence of Pages '09 in both Applications, and the Applications/iWork '09 folders. These are the locations originally installed to if purchased from the OS X app store, or from the iWork '09 DVD respectively. The installation of Pages v5+ will create the iWork '09 folder it is does not already exist, and silently move the Pages '09 app into it. If no Pages '09 application is found, the script will alert to this fact, and then quit. Also added successful testing on Mountain Lion (10.8.5).


Same installation instructions as previous release.


AppleScript code:

(*

Name: rtf2doc.applescript

Usage: Drag/drop Desktop conversion application

Input: Individual File(s) and/or folder(s) of RTF/RTFD documents

Output: Word .doc file written back to original input file location

Assume: Pages '09 is located in Applications/iWork '09 folder

Tested: OS X 10.8.5, 10.9.5, 10.10.5, 10.11.0

Author: VikingOSX, Apple Support Community, Oct. 2015

Rev: 1.2

*)





property allowed_extensions : {"rtf", "rtfd"}

property Pages09 : ((path to applications folder) as text) & "iWork '09:" & "Pages.app:"



-- drop target for files and folders

on open of fileObjects


set code_block to "Main" -- help err_handler identify error location in code


if have_pages09() is false then

display alert "No Pages '09 application is installed … cannot proceed" giving up after 10

quit

end if


try

repeat with aFile in fileObjects


set itemProp to (info for (aFile as alias))


if kind of itemProp is "Folder" then

tell application "Finder"

-- drill down into entire dropped folder hierarchy

set rtf_list to (every item in the entire contents of folder aFile whose name extension is in allowed_extensions) as alias list

end tell

repeat with anItem in rtf_list

process_rtf(anItem)

end repeat

else if name extension of itemProp is in allowed_extensions then

process_rtf(aFile as alias)

end if

end repeat


on error errmsg number errnbr

err_handler(code_block, errnbr, errmsg)

quit

end try


tell my application "Pages" to if it is running then quit

return

end open



on process_rtf(theFile)


set code_block to "process_rtf"

try

-- trim name extension from file

tell application "Finder"

if length of ((name extension of theFile) as text) is 4 then

set wordDoc to text 1 thru -6 of (theFile as text) -- remove rtfd

else

set wordDoc to text 1 thru -4 of (theFile as text) -- remove rtf

end if

end tell


-- add new extension for output file

set wordDoc to wordDoc & "doc"


tell my application Pages09

open theFile

save front document as "Microsoft Word 97 - 2004 document" in wordDoc

close front document saving no

end tell


on error errmsg number errnbr

err_handler(code_block, errnbr, errmsg)

quit

end try


return


end process_rtf



on have_pages09()


local confirmed

set confirmed to false as boolean


-- Check two possible locations for Pages '09

tell application "Pages"

-- Pages '09 from OS X App Store and Pages v5+ is not installed

if its version is greater than "4.0" and its version is less than or equal to "4.3" then

-- reset the property Pages09 here

set Pages09 to {default application} of (info for (path to it)) as text

set confirmed to true

else

try

-- Pages '09 from iWork '09 DVD, or moved by Pages v5+ installation

Pages09 as alias -- shorthand test for if it exists

set confirmed to true

on error

-- remains false

end try

end if

end tell


return confirmed


end have_pages09



on err_handler(location, nbr, msg)


-- dialog will self-destruct in 15 seconds

display alert "RTF to Word Application Error" message "Location: " & location & return & "[" & nbr & "]: " & msg ¬

as critical giving up after 15


tell my application Pages09 to if it is running then quit


return


end err_handler

Mar 7, 2013 8:45 AM in response to Peter Norman1

RTFD can be converted to DOC and DOCX via TextEdit, using the Save as.... menu item.


Here's a write-up from a while back, and I have confirmed that the Word 97 DOC, Word 2003 XML, and Word 2007 DOCX exports do all still exist in 10.7 and 10.8. I don't have Microsoft Word handy to test the imports of those formats.


In OS X 10.8, you do need to hold the Option ⌥ key to get the Save As... option to appear in the menus.


FWIW, I don't know why you responded to Etresoft in the way that you did, as the answer that was provided was and is entirely correct.

Mar 7, 2013 9:43 AM in response to MrHoffman

Hi MrHoffman!


Many thanks for that information!


Years ago, TextEdit provided all those supported file-formats in the default Save As dialog box but now it only offers RTFD and WebArchive.


I didn't know about the hidden trick required to reveal the other file formats (doc, html, odt, xml, etc). Thats good news because it means that all the tools required to convert RTFD into a cross-platform format are already available in OS X, so an AppleScript or Automator-based stand-alone automated converter is possible. I've posted to MacScripter.net and will report back here if I turn up any useful scripts.


I responded to Etresoft in the way I did because he/she was patronizing and the answer provided was NOT correct - Save As is not available in TextEdit without the hidden trick of holding down the Option key.


You, on the other hand, kindly provided that crucial missing piece of info, tested TextEdit yourself in an effort to ensure that the info you provided was correct AND helpfully provided a link to further information.


Is it really necessary to distinguish your polite, correct and helpful approach from Etresoft's patronizing, incorrect and hit and run approach to tech support? Come on! You rock, he doesn't.


Thanks very much!

Peter

Mar 7, 2013 7:45 AM in response to Peter Norman1

Pages '09 v4.3/ OS X 10.8.2.


I just opened a .rtfd file in Pages. When I exported it as Word and reopened in Pages (or LibreOffice 4 Writer), the document looked exactly as it did in the original .rtfd file format. Yes, I know this is not a thorough test, as I have no access to MS Word on either platform to determine if the .doc file retains the image content.

Sep 30, 2015 9:57 AM in response to dsiegel06

I have the majority of a drag/drop Applescript solution completed that uses Pages '09 to open RTF/RTFD documents, and export these to Word DOC. Pages '09 does not support DOCX for export. TextEdit can open RTFD documents, but its export is limited to the same format, or a webarchive. It doesn't even want to consistently export RTF to any other format either, which was maddening, as it should do this. Textutil is an OS X command-line utility that one uses in the Terminal. It can process RTF/RTFD very quickly, and output them to Word DOCX, but strips all text attributes, images, and hyperlinks from the DOCX documents. I wanted to use that as it would have been much less coding. So, the winner is Pages '09.


Right now, I am finishing the debug of a handler before I post the AppleScript here for you.

Nov 3, 2014 2:24 PM in response to Peter Norman1

If you have Pages 09 installed, this is far easier:

  • Find the rtf or rtfd file(s) you need to to convert in Finder.
  • Right click the document and choose "Open with".
  • Select Pages 09 in the popup list and hit Enter - the document will be converted and opened in Pages 09.
  • Save and open it in latest version of Pages (currently 5.5), either by right-clicking from Finder and Open with Pages 5.5, or by starting Pages and opening it through Pages normal Archive/Open command.


All formatting, pictures etc will be preserved.


As a note, I find it very strange that the new Pages 5.5 does not offer an "Import" command for files from the Texteditor, and/or the possibility to import by right clicking in Finder. (Apple - fix this please.)


(Tested on Pages version 4.3 (Pages 9) and 5.5 on Yosemite OS X 10.10)

Jul 26, 2013 2:15 PM in response to MrHoffman

Running 10.8.4.


Its a RTFD file with tables and images.


Pressing OPTION key gives the Save As... menu.


Only two output file options are available from the Save As dialog. Rich Text Document with Attachments and Web Archive.


However if I open a RTF file and do Save As... then all the output options are available.


So I guess its not happy trying to save an RTFD to Doc.

Mar 7, 2013 8:11 AM in response to etresoft

Etresoft,


Your response is not helpful but it demonstrates how you've racked up so many points.


Proof that your response is not helpful AND that you don't actually know what you're talking about:

- TextEdit's SaveAs offers only WebArchive and RTFD as file-formats

- Just so we're clear, those are NOT actual cross platform formats


Please stop wasting people's time and getting in the way of people who are trying to help.

Jul 26, 2013 7:52 AM in response to duncang

Please describe exactly what you've tried here, what sort of file you've opened (rtfd?), what happened, what OS X version you're running, whether you've tried holding the option key as described earlier if you're running 10.8, and also what diagnostics you've received if any.


That written and having just tried this on 10.7.5, I don't see the alternate export options listed for RTFD-format files.


The command-line textutil --convert is still available in 10.7.5 as described in the linked article. Well, at least the man page still exists in 10.7.5, and still lists that option. I haven't tried converting RTFD, and still don't have Office handy to test the import.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Convert RTFD to Doc (without losing images)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.