Automatically convert Pages documents to Word with Automator?

Hey everyone,
I use Pages at home and Word at school. It's really annoying having to save two times every single time I've finished with a document so I was wondering:

Is there a way to tell Automator to look in a specific folder for Pages documents, copy them, then convert the copy to a Word compatible format? (doc / docx)

This would be a great timesaver if it's possible!

MacBook Late 2008, Mac OS X (10.5.8), http://tobynonline.com

Posted on Aug 25, 2009 2:31 AM

Reply
6 replies

Aug 25, 2009 3:06 AM in response to MacUser1001

Go to my iDisk:
<http://idisk.me.com/koenigyvan-Public?view=web>
Download:
For_iWork:iWork '09:for Pages09:batchPages2Doc.zip

You may also run this script:

--

--[SCRIPT touchIworkPlists]
property applyToIwork09 : true
(* true = apply to iWork '09
false = apply to iWork '08 *)
--=====
on run
if applyToIwork09 then
set iworkNum to 9
(* for Pages '09 *)
set pagesStrings to {"Microsoft Word document", "Microsoft Word 97 - 2004 document"}
(* for Numbers '09 *)
set numbersStrings to {"Microsoft Excel workbook", "Microsoft Excel 97-2004 workbook", "Microsoft Excel macro-enabled workbook"}
else
set iworkNum to 8
(* for Pages '08 *)
set pagesStrings to {"SLDocumentTypeMSWord"}
(* for Numbers '08 *)
set numbersStrings to {"LSDocumentTypeExcel"}
end if
my touchPlist("Pages", iworkNum, pagesStrings)
my touchPlist("Numbers", iworkNum, numbersStrings)
end run
--=====
on touchPlist(theApp, num, lStrings)

set thePlist to (path to applications folder as text) & "iWork '0" & num & ":" & theApp & ".app:Contents:Info.plist"

tell application "System Events"
set InfoRecord to (get value of property list file thePlist)
end tell

set CFBundleDocumentTypes to get |CFBundleDocumentTypes| of InfoRecord

repeat with i from 1 to count of CFBundleDocumentTypes
if |CFBundleTypeName| of item i of CFBundleDocumentTypes is in lStrings then
set |CFBundleTypeRole| of item i of CFBundleDocumentTypes to "Editor"
end if
end repeat

set |CFBundleDocumentTypes| of InfoRecord to CFBundleDocumentTypes

tell application "System Events"
set value of property list file thePlist to InfoRecord
end tell
end touchPlist
--=====
--[/SCRIPT]
--


It will allow you to use Save to save as .doc a document which was a .doc when you opened it.

Yvan KOENIG (VALLAURIS, France.) mardi 25 août 2009 12:06:12

Aug 25, 2009 3:47 AM in response to MacUser1001

MacUser1001 wrote:
Thanks for the quick reply!
The Batch script on your iDisk was great but how would I tell it to save the .doc files in the same folder as the Pages file?


Edit the instruction defining the target folder to fit your needs.

In my script there is this instruction:

--

set dossierDeStockage to my creeDossierDeStockage() (* Unicode text *)
--

replace it by

--

set elem to (item 1 of sel) as Unicode text
tell application "System Events" to tell disk item elem
if class is folder then
set dossierDeStockage to elem
else
set dossierDeStockage to path of container
end if
end tell
--


But the folder will become a mess because it will contain the .pages documents as well as the .doc ones.

Also, with the script you posted, I've copied it into Script Editor but how do I save it so it does as you've described?


As with every application, use the File > Save menu item.
In fact you may apply it without saving.

Check that Pages and Numbers are closed then click the Button "Execute" (the green one with a black triangle).
It will change some resources so, the Apps behavior will be changed.

Yvan KOENIG (VALLAURIS, France.) mardi 25 août 2009 12:47:42

Aug 25, 2009 9:28 PM in response to MacUser1001

I wonder if the "watch me do" automator action could be handy for this. What I was thinking is you could use it to record doing a save followed by an export. Then you can play that back. Just be sure to include all necessary steps. I have not done this in Pages but in Numbers I recorded the following:

Click Numbers on the dock
Click File menu
Save
Click Share menu
Export
Click Excel (even if it is already selected)
Click Next
Choose the destination folder (even if the right one is already selected)
Click Export

Set playback speed to 10x. When playing it back, if the Excel version is already there you will get the normal prompt for whether you want to replace it.

You should be able to do the same kind of thing with Pages. It's kind of fun seeing it play it back in front of your eyes.

Sep 13, 2009 3:18 AM in response to MacUser1001

Apply this enhanced version which is able to restore original settings.

--

--[SCRIPT touchIworkPlists]
(*
2009/09/12 now may restore original settings.
*)
property applyToIwork09 : true
(* true = apply to iWork '09
false = apply to iWork '08 *)
--=====
on run
if applyToIwork09 then
set iworkNum to 9
(* for Pages '09 *)
set pagesStrings to {"Microsoft Word document", "Microsoft Word 97 - 2004 document"}
(* for Numbers '09 *)
set numbersStrings to {"Microsoft Excel workbook", "Microsoft Excel 97-2004 workbook", "Microsoft Excel macro-enabled workbook"}
else
set iworkNum to 8
(* for Pages '08 *)
set pagesStrings to {"SLDocumentTypeMSWord"}
(* for Numbers '08 *)
set numbersStrings to {"LSDocumentTypeExcel"}
end if
set {btn1, btn2, btn3} to {"Cancel", "Reset original", "Save Office docs"}
set what to display dialog "What to do ?" buttons {btn1, btn2, btn3}
set what to button returned of what
if what is btn1 then error number -128
if what is btn3 then
set what to "Editor"
else
set what to "Viewer"
end if

my touchPlist("Pages", iworkNum, pagesStrings, what)
my touchPlist("Numbers", iworkNum, numbersStrings, what)

end run
--=====
on touchPlist(theApp, num, lStrings, theMode)

set thePlist to (path to applications folder as text) & "iWork '0" & num & ":" & theApp & ".app:Contents:Info.plist"

tell application "System Events"
set InfoRecord to (get value of property list file thePlist)
end tell

set CFBundleDocumentTypes to get |CFBundleDocumentTypes| of InfoRecord

repeat with i from 1 to count of CFBundleDocumentTypes
if |CFBundleTypeName| of item i of CFBundleDocumentTypes is in lStrings then
set |CFBundleTypeRole| of item i of CFBundleDocumentTypes to theMode
end if
end repeat

set |CFBundleDocumentTypes| of InfoRecord to CFBundleDocumentTypes

tell application "System Events"
set value of property list file thePlist to InfoRecord
end tell
end touchPlist
--=====
--[/SCRIPT]
--


Yvan KOENIG (VALLAURIS, France) Sunday, September 13, 2009 12:18:18

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.

Automatically convert Pages documents to Word with Automator?

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