Apple Event: May 7th at 7 am PT

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

Auto-Convert Pages Documents to Word Documents

Is there any automated way of converting Pages 4.3 documents to MS Word document format?

I know that I can open each one in Pages and Export them, but prefer not to have to manually do it to all my files.


Switching to MS Word so, I'd like to move all my existing Pages docs to Word format. Tired of this 1 step forward, 5 steps back approach of Apple when it comes to their productivity apps. They cease to be productivity apps.

Posted on Nov 8, 2013 2:31 PM

Reply
22 replies

Mar 8, 2014 6:00 PM in response to nscozzaro

bryanbeus and nscozzaro: thanks a ton for posting these scripts. I tried both, but as a AppleScript newbie I couldn't get past the following syntax error when I pressed compile:



"Expected end of line, etc. but found “front”."



...with the following "front" highlighted in the script:

"export front document to POSIX file theFolder as Word"



I am on an old iMac running 10.5.8 trying convert to Word from Pages before backing up all files and upgrading my machine and OS. Pages is version 3.0.3. ScriptEditor is Version 2.2.1 (100.1). AppleScript is version 2.0.1.



Any ideas on how I can adjust the script to get it to work?



[

Similar to foxygenn: I was able to compile the first script suggestion from Edward Cross, but when I dragged and dropped it came up with the following error:


"The document cannot be exported to the "Microsoft Word 97 - 2004 document" format."


I tried replacing the phrase in the script with WORD and .doc but got the same message.

]



Thanks much to anyone for any help.

Mar 8, 2014 6:16 PM in response to zwg2

Ok maybe nevermind. Looks like I got the following to work, which suits my needs for now. It uses the Edward Cross version above with the only change being from


" ...save front document as "Microsoft Word 97 - 2004 document"... "


to


"save front document as word"


See below for full script. So far so good.




onopentheFiles


tellapplication"Pages"


repeatwithaFileintheFiles


openaFile


setdocNametonameoffrontdocument


-- Remove .pages extension.


setprevTIDstoAppleScript'stext item delimiters


setAppleScript'stext item delimitersto".pages"


-- Add .doc extension.

set docName to first text item of docName & ".doc"


setAppleScript'stext item delimiterstoprevTIDs


-- Get folder that dropped file exists in.

tell application "Finder"


setsourceFolderto(containerofaFile)asUnicode text

end tell -- Finder


-- Save file to folder that dropped file exists in.


setdocPathAndNametosourceFolder&docName


savefrontdocumentaswordindocPathAndName


closefrontdocument


endrepeat


endtell

endopen

Mar 8, 2014 8:42 PM in response to zwg2

That's interesting that that works for you... your edit was the first thing that I tried, but on my machine (MacBook Pro, early 2011 running OS X 10.9.2) I get the error "Can't make <<constant ****Pwrd>> into type constant".


I don't know what that error means, or how to debug it, and it's frustrating that it doesn't work!

Mar 15, 2014 8:20 AM in response to Edward Cross

Thank you all for the wonderful script!

I extended the script: You can select a folder in the file-editor. The structure is examined recursively: In this folder and in all sub-folders all ".pages"-documents are taken and converted to word-documents. It might help some people:



tell application "Finder"

set theFolder to choose folder

set theList to entire contents of theFolder as alias list

repeat with thisItem in theList

set nameItem to name of thisItem

set kindItem to kind of thisItem

-- if it is a folder, kindItem is "Folder".

-- if it is a pages document, kindItem is "Pages Publication".


if kind of thisItem is "Pages Publication" then -- only pages documents are considered

-- here the pages-documents are converted to a word-document

tell application "Pages"

open thisItem -- The file is opened in pages

set docName to name of front document

-- Remove .pages extension

set prevTIDs to AppleScript's text item delimiters

set AppleScript's text item delimiters to ".pages"

-- Add .doc extension.

set docName to first text item of docName & ".doc"

set AppleScript's text item delimiters to prevTIDs

-- Get folder of the file

tell application "Finder"

set sourceFolder to (container of thisItem) as Unicode text

-- display dialog sourceFolder

end tell -- Finder

-- Save file to the same folder

set docPathAndName to sourceFolder & docName

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

close front document

end tell

end if

end repeat

end tell

Auto-Convert Pages Documents to Word Documents

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