Could sanyone help with this script to batch convert pages files to pdf?

I found this from the Google AI, but Automator returned an error. MBP running macOS Version 15.6.1 (24G90).


Please see below:


on run {input, parameters}


    repeat with aFile in input


        tell application "Finder"


            set {tName, fileExt} to {name, name extension} of aFile


            if fileExt is "pages" then


                set out_file to (text 1 thru -((count of fileExt) + 2) of tName) & ".pdf"


                set theFolder to (get container of aFile)


                set outPath to (theFolder as text) & out_file




                tell application "Pages"


                    set mydoc to open aFile


                    export mydoc to file outPath as PDF


                    close mydoc saving no


                end tell


            end if


        end tell


    end repeat


    return input


end run






The action "Run AppleScript"


encountered an error: "The


operation couldn't be completed.


(com.apple.Automator error


-212.)"


Thanks in advance


pqb

MacBook Pro 13″, macOS 15.6

Posted on Oct 21, 2025 8:49 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 23, 2025 6:37 AM

Beginning with macOS Sequoia, Apple introduced a Shortcut action that converts Pages documents to PDF without ever needing to launch Pages. I have written a Shortcut Quick Action that allows you to right-click on one.or several selected Pages documents and export them as PDFs. Same document name, same location. No AppleScript code.


  1. Click on this link to prompt your Shortcuts application to ask you to install the Quick Action named Export Pages to PDF.
  2. Visit System Settings > General > Login Items & Extensions > By Category
    1. Locate and click Finder i⃝ and on the panel that appears, scroll down until you find Export Pages to PDF and enable (==⦿) it.


Now, select one or more (cmd-key) Pages documents in the Finder. Right-click on the first selected document, and from the secondary Finder menu, choose Quick Actions > Export Pages to PDF. The Quick Action may pop a dialog asking for permission of some sort and you click OK to continue. There will be no indication other than the appearance of PDFs in the Finder that the Quick Action has completed. In previous AppleScript-based solutions, I used a counter for each export and provided a dialog after the last export had completed.


Here is the actual Export Pages to PDF Shortcuts action that you are installing:



The Source Password in the Export action is blank, so no password is set on the exported PDF.


Tested on macOS Sequoia thru 15.7.1 and Tahoe 26.0.1.

16 replies
Question marked as Top-ranking reply

Oct 23, 2025 6:37 AM in response to Peter Blackburn

Beginning with macOS Sequoia, Apple introduced a Shortcut action that converts Pages documents to PDF without ever needing to launch Pages. I have written a Shortcut Quick Action that allows you to right-click on one.or several selected Pages documents and export them as PDFs. Same document name, same location. No AppleScript code.


  1. Click on this link to prompt your Shortcuts application to ask you to install the Quick Action named Export Pages to PDF.
  2. Visit System Settings > General > Login Items & Extensions > By Category
    1. Locate and click Finder i⃝ and on the panel that appears, scroll down until you find Export Pages to PDF and enable (==⦿) it.


Now, select one or more (cmd-key) Pages documents in the Finder. Right-click on the first selected document, and from the secondary Finder menu, choose Quick Actions > Export Pages to PDF. The Quick Action may pop a dialog asking for permission of some sort and you click OK to continue. There will be no indication other than the appearance of PDFs in the Finder that the Quick Action has completed. In previous AppleScript-based solutions, I used a counter for each export and provided a dialog after the last export had completed.


Here is the actual Export Pages to PDF Shortcuts action that you are installing:



The Source Password in the Export action is blank, so no password is set on the exported PDF.


Tested on macOS Sequoia thru 15.7.1 and Tahoe 26.0.1.

Oct 21, 2025 11:43 AM in response to Peter Blackburn

Would you be happier with a macOS Shortcut that uses an action that exports the Pages documents to PDF without launching and flashing the Pages application for each file, and quietly writes the PDF in the same location as the source Pages document? I already have the Shortcut written and working on Sequoia and Tahoe.


If not, we can clean up your AppleScript if you want to see Pages open every document and export to PDF. Personally, I like a solution that does not show anything on the Desktop.


With Automator, it is always best to get the Run AppleScript code working in Script Editor beforehand so you have some improved debugging feedback.


Oct 26, 2025 6:53 AM in response to Peter Blackburn

The second Shortcut only opens a final dialog with the count of exported PDFs. When you initially ran it, a dialog appeared with the Pages document appearing in it and asking to "Allow "Export Pages to PDF w/Count" to share 1 file with "Pages"? You should respond with Always Allow, because if you choose Allow Once, you will see this dialog again as part of the workflow.


I only see the following dialog on macOS 15.7.1:



However, either it is too early on Sunday or I am not finding the exported PDF, so more investigation here… Testing with a Parallels Desktop Pro Sequoia v15.7.1 guest. Also noticed the absence of a selected Provide Output on the Details panel, but that makes no difference. Will try this Shortcut on my MacBook Pro running Sequoia.

Oct 24, 2025 6:11 AM in response to Peter Blackburn

My primary Mac is running Tahoe 26.0.1 and I forgot that you were still on Sequoia. Those settings are:


  1. System Settings > General > Login Items & Extensions
    1. Under the Extensions heading, click on Finder i⃝, then locate the new Shortcut name and enable it.


Apple constantly changing things… 🧐


Late yesterday, I revised a copy of this Shortcut to count exported PDFs and pop a dialog of that file count upon completion — if you think you want that after trying the current Shortcut.

Oct 25, 2025 1:02 PM in response to Peter Blackburn

Thought I would post a modification to the previously posted Shortcut. It does everything the original does, but also maintains a count of the exported Pages documents and when finished, pops a dialog show that export count.


To install the updates Shortcut, click here and follow the Shortcut app's dialogs and the original instructions to enable the Shortcut in Sequoia. If using macOS Tahoe, Apple has added some additional System Settings navigation to enable the Shortcut:


System Settings > Login Items & Extensions > Extensions By Category > Finder i⃝


Oct 26, 2025 12:40 AM in response to VikingOSX

Thanks again. That is useful to check whether I have converted all the files.


I have tried this, but it seems not to save the pdf files. It does generate the popup dialogue.


The original, and the new shortcut, show a dialogue box for the first two files, then it proceeds without that. If I try further actions using the short cut the dialogue box does not appear. Not a serious issue for me as the shortcut saves a lot of time.


pqb


Could sanyone help with this script to batch convert pages files to pdf?

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