Convert .pages files to word (or rtf) in bulk

I need to convert plenty of .pages files to word or alternatively to rtf . They are just too many to do one by one. Is there any way to do that in bulk using automator or terminal?


I have already tried with the solution suggested here: Batch Convert pages to Word Document- Mac… - Apple Community but that has not worked, maybe because I have BigSur 11.6.8

The error message looks like this:



(Translation from Italian: "not authorised to send Apple events to Finder" )


Any suggestions? Thanks in advance!




MacBook Air 13″, macOS 11.6

Posted on Sep 10, 2022 3:27 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 10, 2022 5:35 AM

The code itself works just fine in macOS 11.6.8, and 12.5.1. However, the first time you run the Automator application it will prompt you three times for permissions that you must grant in order for it to proceed. When you agree (select OK) each time, it will update the System Preferences > Security & Privacy > Privacy panel entries to make these permissions permanent. In this case, my arbitrary name for the Automator application is PagesXWord.app.


I exported a 180pp Pages document this morning to Word .docx without issues using this code.


First:



Second:



and finally:



As mentioned previously, the Automator Application requires two actions:

  1. Ask For Finder Items
    1. Start at Desktop
    2. Type: Folders ☑︎ Allow Multiple Selection
    3. Select the Pages folder, press the ⌘-key, and then select the output folder for the exported Word docx
  2. Run AppleScript
    1. Remove all default boilerplate content from this action and replace it with the AppleScript in the original post.
    2. The on quit handler should read: on quit and not on quit {}.


Here is the updated comment section for that AppleScript:


(*
 The script converts Pages documents found in the source folder to Word (.docx) documents
 in the output folder.

 Intended to be used in an Automator application's Run AppleScript action
 Preceded by an Ask for Finder Items action whose type is Folders with Allow Multiple
 Selection, one chooses the folder containing the Pages documents and
 then presses the ⌘+key to select the destination folder. This order is critical.

 Reference: https://discussions.apple.com/thread/253072302
 Tested: macOS 11.5.2 (20G95), Pages 11.1, macOS 10.14.6 (18G9323, Pages 10.1
 Tested Update 2022-09-10: macOS 11.6.8, 12.5.1, Pages 12.1
 VikingOSX, 2021-08-23, Apple Support Communities, No warranties/support expressed or implied.
*)


Hopefully, there are no English<->Italian namespace issues for quoted names as AppleScript is not auto-language sensing.


As Pages is no Word clone, the content of your existing Pages documents may not appear in Word format as it does in Pages. It might be better to achieve a visually faithful export to PDF, and then use MS Word v16.31 or later to open those PDFs and create Word .docx documents from them.

6 replies
Question marked as Top-ranking reply

Sep 10, 2022 5:35 AM in response to 20Pepe16

The code itself works just fine in macOS 11.6.8, and 12.5.1. However, the first time you run the Automator application it will prompt you three times for permissions that you must grant in order for it to proceed. When you agree (select OK) each time, it will update the System Preferences > Security & Privacy > Privacy panel entries to make these permissions permanent. In this case, my arbitrary name for the Automator application is PagesXWord.app.


I exported a 180pp Pages document this morning to Word .docx without issues using this code.


First:



Second:



and finally:



As mentioned previously, the Automator Application requires two actions:

  1. Ask For Finder Items
    1. Start at Desktop
    2. Type: Folders ☑︎ Allow Multiple Selection
    3. Select the Pages folder, press the ⌘-key, and then select the output folder for the exported Word docx
  2. Run AppleScript
    1. Remove all default boilerplate content from this action and replace it with the AppleScript in the original post.
    2. The on quit handler should read: on quit and not on quit {}.


Here is the updated comment section for that AppleScript:


(*
 The script converts Pages documents found in the source folder to Word (.docx) documents
 in the output folder.

 Intended to be used in an Automator application's Run AppleScript action
 Preceded by an Ask for Finder Items action whose type is Folders with Allow Multiple
 Selection, one chooses the folder containing the Pages documents and
 then presses the ⌘+key to select the destination folder. This order is critical.

 Reference: https://discussions.apple.com/thread/253072302
 Tested: macOS 11.5.2 (20G95), Pages 11.1, macOS 10.14.6 (18G9323, Pages 10.1
 Tested Update 2022-09-10: macOS 11.6.8, 12.5.1, Pages 12.1
 VikingOSX, 2021-08-23, Apple Support Communities, No warranties/support expressed or implied.
*)


Hopefully, there are no English<->Italian namespace issues for quoted names as AppleScript is not auto-language sensing.


As Pages is no Word clone, the content of your existing Pages documents may not appear in Word format as it does in Pages. It might be better to achieve a visually faithful export to PDF, and then use MS Word v16.31 or later to open those PDFs and create Word .docx documents from them.

Sep 12, 2022 5:11 AM in response to 20Pepe16

Once those three dialogs are satisfied, either currently when running Automator, or from some other prior application resolving them, they do not repeat, so understandable that you may not receive all three of those challenges.


There are two ways to design this Automator application: 1) Three actions where you are sequentially prompted for the source folder containing the Pages documents, and then a second prompt for the destination folder to receive the Word documents, or 2) One Ask for Finder Items action that allows multiple selections to first specify the Pages folder, and then by pressing the ⌘-key, clicking the destination folder. In either scenario, two folder paths are passed to the Run AppleScript action in their selection order.


This solution is currently written to expect a source folder and a destination folder. If you want the Desktop as the source folder and the Desktop again as the destination folder, that will work with the two prompt [1] implementation above as you just click choose on each dialog. It won't work with the one-prompt, multiple-selection version.


Automator applications are intended to be saved to the Desktop where they are double-clickable. I usually leave them there, or maybe drag them into the /Applications folder, but never attempt to save them anywhere but the Desktop. I have also never received the code-signing error or any error regarding the CommandLine Tools and I am running macOS 11.6.8. That xcrun application is in /usr/bin, not in the CommandLine tools path that it proclaimed as missing on that dialog.


When you dragged the Run AppleScript action to the main workflow window, did you remove all default content, before pasting in the entire code provided in the original post?


I can build this solution from scratch using either [1] or [2] design scenarios from above and it just saves and works correctly without any errors. Perplexed that it does not work for you…

Sep 12, 2022 2:40 AM in response to VikingOSX

Thanks for the prompt reply!

I've tried several times following your instructions step by step but did not succeed.

The first time it asked me the permissions but just once (not three times). When I then tried to convert the files the app just stopped running.

Then I tried again to create the app starting from scratch. It did not prompt me for the permissions anymore and just gave me the old error message I have already reported above.

I don't know whether this is relevant, but all the times I tried to save the app on the desktop after creating it on automator, it gives me this error message (I have changed the language for Automator, so that we don't have communication issues)



But then it anyways saves the app on the desktop.


There is something in the additional explanations you provided which I don't understand


As mentioned previously, the Automator Application requires two actions:
Ask For Finder Items
Start at Desktop
Type: Folders ☑︎ Allow Multiple Selection
Select the Pages folder, press the ⌘-key, and then select the output folder for the exported Word docx
Run AppleScript
Remove all default boilerplate content from this action and replace it with the AppleScript in the original post.
The on quit handler should read: on quit and not on quit {}.

The third passage you mention for the "Ask for finder Items" (i.e. Select the Pages folder, press the ⌘-key, and then select the output folder for the exported Word docx) is completely new and you did not mention it in the previous post. Can't I just leave the input as it is (i.e. start at Desktop)? In any case, I have also tried specifying the input and output folders but it did not work.


Thanks again for the patience and the help


P.s. For me it is not such a big deal that the formatting of the converted word files is messed up. The important thing is that the contents are preserved.

Sep 12, 2022 8:52 AM in response to VikingOSX

Thanks for your explanation! The difference between the two application designs is now clear.

I have tried with both the designs of the Automator application you outlined but in both cases the error message is the "[- 1743] not authorised to send Apple events to Finder" which I have reported above. I really wonder why this happens...

I did remove the entire default content on the workflow window before copy-pasting the whole code you provided in the old post.

I have tried this several times looking for possible mistakes at each passage. It looks to me that I have followed all the steps.


Thanks again for your help

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 .pages files to word (or rtf) in bulk

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