Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Problems with batch convert Pages to pdf script

Hi! I have like 200 hundred pages files that need to be converted into PDFs, and when I saw @VikingOSX's Script to batch convert .pages to PDF I thought IO was saved... but not yet.


I have not much experience with AppleScript, but the instructions were quite clear, I copied the code (the newest sanitised version from 2021 (found here: https://discussions.apple.com/thread/252573313), created the applescript and the drag and drop app.


When I dropped a pages it asked for permission (although only once), then I got a message saying "Export complete. Files exported to PDF: 0"


This has been tried in a M1 Mac Studio with the latest Sonoma version and in an Intel's Mac Book Pro with Ventura, to see if it was something to do with Sonoma. But I've got the same results.


Is there any hint I've been missing or a probable solution, please?


Thanks for such a dedicated work on Support!

Posted on Nov 9, 2023 6:05 PM

Reply
Question marked as Best reply

Posted on Nov 10, 2023 12:50 PM

Let's walk though the steps again.


  1. Copy and paste the entire code in the last source code that I posted today at 9:42 am — into a new, open Script Editor window. Click the hammer icon to compile and test for syntax errors.
  2. Save that script as an AppleScript via Save…
    1. File format: Text
    2. Line Endings: No change
    3. Save as: something.applescript
    4. Save
  3. Option+Save As…
    1. File format: Application
    2. Line Endings: No Change
    3. Save as: something.app on your Desktop
    4. Save
    5. Quit Script Editor
  4. If you are using Stacks, click on the Applications stack to expose your saved application.
  5. Select multiple Pages documents with the ⌘-key and then drag over the application icon.
    1. Pause for 1 - 2 seconds to get the translucent box around the application icon, its file count, and then release the Pages documents.
  6. The application should cycle Pages through its open/export process for each document and when done, present the count dialog as I have posted previously.
    1. Options: Nothing selected
  7. PDFs will be created at the same location as the original Pages documents.
14 replies
Question marked as Best reply

Nov 10, 2023 12:50 PM in response to Joan O.

Let's walk though the steps again.


  1. Copy and paste the entire code in the last source code that I posted today at 9:42 am — into a new, open Script Editor window. Click the hammer icon to compile and test for syntax errors.
  2. Save that script as an AppleScript via Save…
    1. File format: Text
    2. Line Endings: No change
    3. Save as: something.applescript
    4. Save
  3. Option+Save As…
    1. File format: Application
    2. Line Endings: No Change
    3. Save as: something.app on your Desktop
    4. Save
    5. Quit Script Editor
  4. If you are using Stacks, click on the Applications stack to expose your saved application.
  5. Select multiple Pages documents with the ⌘-key and then drag over the application icon.
    1. Pause for 1 - 2 seconds to get the translucent box around the application icon, its file count, and then release the Pages documents.
  6. The application should cycle Pages through its open/export process for each document and when done, present the count dialog as I have posted previously.
    1. Options: Nothing selected
  7. PDFs will be created at the same location as the original Pages documents.

Nov 13, 2023 9:44 AM in response to VikingOSX

Ok. It worked, but allow me to elaborate for future reference, because I was going crazy :)


I did exactly what you said, Even closed all the other programs I had opened or the resident ones like CleanMyMac just in case.


Same result. No PDF.


I even tried on a friend of mine… with the same result. So I started to wonder… it's not possible that something like this doesn't work on different macs but yours, because I (of course) trust your process… and I thought what possible things could be different on my Macs from yours...


LANGUAGE.


I switched my macbook pro from Spanish to English as a default language, restarted… AND IT WORKED!


Thank you for all your help, and now you know, your script only works with English as the Computer's language :)



Nov 10, 2023 6:42 AM in response to Joan O.

Joan,


Looking into this now. I am on macOS 14.1.1 and Pages v13.2.


The code that you linked to works correctly with the first sentence versions, but does not include a completion dialog with file count. Other Pages to PDF scripts that I have written do include that dialog tally and the following was generated with different code whether individual files or a folder containing these files was dropped on the application:



The following (different) code has been tested and works to produce corresponding PDF files from Pages documents. Give it the same application name as you did previously so you don't have another series of security dialogs wanting to do something…



Nov 13, 2023 8:01 AM in response to Joan O.

I copied and pasted the exact code that you just posted, then:


  1. File : Save…
    1. Save As: p2pdf.applescript
    2. Desktop
    3. File Format: Text
    4. Options: None selected
    5. Save
  2. Option + File : Save As…
    1. Save As: p2pdf.app
    2. Desktop
    3. File Format: Application
    4. Options: None Selected
    5. Save


At this point, quit the Script Editor.


I then selected three random Pages documents on my Desktop and then dragged onto the p2pdf.app icon, paused 1 - 2 seconds for the transparent surround on that app icon and the red counter of files to drop, then released (drop). Do not click cancel on any dialog asking for permission to do something, and in my case, the export of those three Pages documents resulting in three comparable PDFs.


Tested: Sonoma 14.1.1 on an M2 Mac mini Pro with Pages v13.2.

Nov 10, 2023 7:40 AM in response to VikingOSX

First of all, thank you for answering so fast!


It looks better… but it's still not working, but it gave more more information… when I drop the pages document this is the answer I get:



Which I don't understand… because they are pages documents...


In fact, just to test I've created a new pages document from scratch using one of the template options the soft provides… and I get the same result.


For some reason it is not recognizing my pages document as pages :(


If you want, and only for the sake of testing, this is the newly created file, that I'm sure your system will recognize, but just to be sure..


Here was a link to the file in dropbox. Sorry I wasn't aware it wasn't allowed.


If this may inspire you on why my system (same as yours) is it not accepting my pages as pages files, it would mean the world.


Thank you!


[Edited by Moderator]

Nov 10, 2023 8:02 AM in response to Joan O.

That dialog occurs because the file counter was either zero or simply not used in the code. It has nothing to do with your Pages documents at all, and by the time that dialog appears, your Pages documents should have converted to PDF as expected.


I just copied and pasted the same code I last posted above into Script Editor, and saved as an app on my Desktop. I selected three random Pages documents and dragged them onto the app icon, paused 2 seconds, and released the documents. The PDFs were created and I received:



I would suggest that you revisit copying/pasting the entire code from that expanded additional text accordian, compiling it in Script Editor, and resaving the app on your Desktop. Try dragging/dropping Pages documents again.

Nov 10, 2023 10:56 AM in response to VikingOSX

Thank you, but still couldn't make it work.. I copied exactly the same code from above, double checked, saved as told… to no avail :(


Thank you very much anyway.


I don't know if it could be an option via third party service or something and without breaking community rules to receive your compiled version? Just to, I dunno, see if that works if there's something that my unexperienced self has missed?


If that's not possible, I really appreciated all the help provided!


Nov 12, 2023 4:22 PM in response to VikingOSX

Thank you. Although I'm not a Programmer, I'm quite proficient in the use of computers, and have been using them for years… I've been following to the T's all your instructions, and started all over again with your last list… with the same result :(


Thank you, I really appreciate it.


I even tried opening one doc in Pages and exporting it as PDF, and it did it well… so the possibility exists on my computer… it just doesn't "want to do it" with a Script.


Unless you have a new genius idea, I won't waste more of your time, it's obvious it works perfect for you… and there's something on my setup preventing it to do so.


Thanks!

Nov 13, 2023 10:01 AM in response to Joan O.

Yes, unfortunately, I write code in English and the Script Editor does not automatically convert AppleScript content to the local language as you have discovered. Even if you had mentioned that your local language is Spanish, I would have been hesitant to change the default language on my Mac to Spanish for testing purposes.This has come up before in other languages… so sorry for the aggravation it has caused you.


Can you share what words did not map to the Spanish language in the script and what you had to change? It is possible from within a script to get the local language and then map those words into the AppleScript where they are needed.

Problems with batch convert Pages to pdf script

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