Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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
34 replies

Jul 26, 2013 5:51 PM in response to Peter Norman1

Peter Norman1 wrote:


Why is my original question marked as answered by MrHoffman?

- His answer does NOT answer the question; it is misleading other visitors to the thread


You marked it that way.

- The creator of the thread should have the right to mark the question answered

- There are reports (link) that this is a bug in Apple's forum software thats being abused by users in order to gain points for their profile with each question they have answered and for which they have taken credit

- I cannot turn it off or point to another answer


There are some limitations to the points system. Like any complex system, there are bound to be problems. No one is abusing any bugs to gain points. I can assure you that there are plenty of official and unofficial forum police who check questions, answers, links, disclaimers, etc. and promptly report anything that is anywhere close to unusual.


If MrHoffman is still reading this thread: please disable your originally tagged answer to my question.


Sorry, but you only get one shot (or three) to award points. If you screw up, too bad. No one, certainly not the awardee, can fix it. The hosts won't bother. You have awarded points more equitably that most people do anyway, so what's the big deal?


Ask another question and try to do better next time. However, if you expect to get any answers in the future, you might want to consider a bit more politeness. Like the forum software, OS X is complex and always changing. An answer that was correct last year or last March might not be correct forever. Like someone who prematurely clicks the "solved" button, people who reply don't always test every single response, espeically the obvious ones. It's not worth getting upset over.

Dec 1, 2013 12:20 PM in response to Peter Norman1

Patronizing answers are frequent in the Apple ecosystem, at least in my experience. Especially if you try to do anything your way (instead of the ways Apple prepared for you). I'm sure etresoft didn't mean anything bad, it's more of a folklore in Apple world. People patronize on automation... and usually ask you "...and why do you want to do xyz?" as if you have to justify any free will to them.


EDIT: This is the answer to your post that begins with "Hi MrHoffman! Many thanks for that information!". I'm sure I clicked Reply there, and I'm not sure why my answer was positioned here, neither how I can delete it from here.

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)

Nov 5, 2014 2:08 AM in response to Bikerguru

Bikerguru wrote:

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.)

Because Apple dumbed it down to match the iOS versions. Apple doesn't respond here. If you want to get their attention, File a bug report with Apple.


27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2

Sep 29, 2015 5:24 PM in response to dsiegel06

Debbie, the dead get no rest in this community. 😉


Are all of these documents strictly RTF, or are some of them RTFD with images, etc in them? Converted documents written back to original RTF file location with docx extension, or placed in a converted docx output folder? Either are possible.


There are multiple ways to automate the conversion, but all require programming in AppleScript, or as Bash scripts to setup the processing loop, either as standalone, or integrated into AppleScript or Automator applications.

Sep 30, 2015 6:56 AM in response to VikingOSX

Thanks for your quick response! They were originally evernote notes that I exported using a script. Some originally had images, but the script separates the images into a separate folder. .However, they are all still rtfd even through they contain just text after export. The script exports the file as an html as well.


I don't need the images to be kept intact. I can handle them separately. Does that answer your questions?


Thanks for help with this! I don't know anything about applescript, but would love to.

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.

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 4:37 AM in response to VikingOSX

Belated reply! Thank you for going through this. It didn't work for me sadly. Pages is not in an iWork folder for me. I created such a folder, but it still didn't work. And I did upgrade to El Capitan. So perhaps that is part of the issue? The issue said something to do with Pages. So perhaps the location of Pages was the main issue. The computer came with Pages in its location though.


Any ideas?


Thanks again for your help!

Debbie

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

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 ID.