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

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.