Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Batch convert Pages 5 files to PDF.

Is there a way or an app to batch convert Pages 5 files to PDFs ?

I need to convert about 200 files and doing them individually is

a long project.


Thanks in advance,


Lenny.

Posted on Nov 4, 2014 11:34 AM

Reply
38 replies

Jan 9, 2015 6:05 AM in response to onions83

aha! thanks for the reply. i do not know what i was doing wrong, but putting into script editor and just saving immediately seems to work now.


i am also trying to adapt this to export word files, but I'm getting an error in this screenshot.


i realise this is not really related to the original thread... but my limited knowledge of applescript is not really paying off.


User uploaded file


here is the code I've been playing with:


--Select from where you will pick up the pages files

set theFolder to choose folder with prompt "Select folder with original pages files :"

--Do it

tell application "Finder"

set theNames to name of files of theFolder ¬

whose name extension is "pages"

end tell



--Select where the Word files will go

set docx_Folder to choose folder with prompt "Select folder where Word files will go :"



-- How many files to export

set item_count to (get count of items in theNames)



--Get files and export them

repeat with i from 1 to item_count


set current_file to item i of theNames -- get a file

set lean_file to text 1 thru -7 of current_file & ".docx" -- change the originalfile (.pages) to a .docx name

set out_file to (docx_Folder as Unicode text) & (lean_file) -- get the fully qualified output name

set in_file to (theFolder as Unicode text) & (current_file) -- get the fully qualified input file name


tell application "Pages"

set mydoc to open file in_file -- open input file in Pages

export mydoc to file out_file as docx --do the exporting

close mydoc saving no -- close the original file without saving

end tell


end repeat





display dialog "done" -- Job done

Jan 9, 2015 6:22 AM in response to Erko2

Just figured out the WORD export options too!


This is handy! Thank you guys for the help in getting this script running. I've been itching to get this working again since upgrading to yosemite.



--Select from where you will pick up the pages files

set theFolder to choose folder with prompt "Select folder with original pages files :"

--Do it

tell application "Finder"

set theNames to name of files of theFolder ¬

whose name extension is "pages"

end tell


--Select where the Word files will go

set docx_Folder to choose folder with prompt "Select folder where Word files will go :"


-- How many files to export

set item_count to (get count of items in theNames)


--Get files and export them

repeat with i from 1 to item_count


set current_file to itemi of theNames-- get a file

set lean_file to text 1 thru -7 of current_file & ".docx" -- change the originalfile (.pages) to a .doc name

set out_file to (docx_Folder as Unicode text) & (lean_file) -- get the fully qualified output name

set in_file to (theFolder as Unicode text) & (current_file) -- get the fully qualified input file name


tell application "Pages"

set mydoc to openfilein_file-- open input file in Pages


exportmydoctofileout_fileasMicrosoft Word--do the exporting


closemydocsavingno-- close the original file without saving

end tell


end repeat



display dialog "done" -- Job done

Jan 13, 2015 2:58 PM in response to stgrosso

Hi Stgrosso,


Try this. It's probably not the cleanest way to do it but it basically tells the script to set the output folder as the input folder. Other than that can't help much, I'm no expert at scripting.


--Select from where you will pick up the pages files

set theFolder to choose folder with prompt "Select folder with original pages files :"

--Do it

tell application "Finder"

set theNames to name of files of theFolder ¬

whose name extension is "pages"

end tell


-- How many files to export

set item_count to (get count of items in theNames)


--Get files and export them

repeat with i from 1 to item_count


set current_file to itemi of theNames-- get a file

set lean_file to text 1 thru -7 of current_file & ".pdf" -- change the originalfile (.pages) to a .pdf name

set out_file to (theFolder as Unicode text) & (lean_file) -- get the fully qualified output name

set in_file to (theFolder as Unicode text) & (current_file) -- get the fully qualified input file name


tell application "Pages"

set mydoc to openfilein_file-- open input file in Pages


exportmydoctofileout_fileasPDF--do the exporting


closemydocsavingno-- close the original file without saving

end tell


end repeat



display dialog "done" -- Job done

Jul 20, 2016 4:26 AM in response to onions83

I know this response was like a year and a half ago, but this script works AMAZINGLY well. I'm currently writing a second cookbook and as I'm gathering recipes, each recipe has its own Pages file. It might sound like an odd way to do it, but it allows me to keep everything organized into sections. At any rate, I needed each one converted into a PDF (for various reasons I won't bore you with). This script allows me to do just that in a batches. Do you realize the time you've just saved me? This is fantastic!


Thank you for taking the time to do this. Wonderful stuff 🙂

Jul 20, 2016 5:05 AM in response to VikingOSX

I now have an AppleScript that can be run interactively, or as a drag and drop application. There is some assembly required (two-action Automator workflow needs to be created, and then copy/paste of AppleScript into Script Editor. I will post the code here if there is an interest.


Features:

  • Interactive (double-click)
    • Calls an automator Ask for Finder Items workflow that allows multiple selection of files and folders
    • If Pages v5.6 or later, offers PDF export quality (good, better, best) selection
  • Drag and Drop support
    • Files and/or folders
    • Default PDF export quality is best, or default depending on Pages version.
  • Processing
    • Word and Pages documents
    • PDF written back to original file location
    • PDF extension forced visible in Finder
    • Pages version and PDF quality stamped in PDF document Finder comment field
    • On completion, notification panel slides in with processed file count

Sep 1, 2016 12:28 PM in response to stgrosso

Here is a way simpler script for what you are asking. you just have to drag and drop the files on the script app and it will convert and export to the original location.


Pages to PDF


on open fs

my proceed:fs

end open


on proceed:fs

tell application "Finder"

repeat with i from 1 to (get count of items in fs)

if (name extension of item i of fs) is "pages" then

set PDFfile to text 1 thru -7 of (item i of fs as text) & ".pdf"

tell application "Pages"

set mydoc to open (itemi of fs) -- open input file in Pages


exportmydoctofilePDFfileasPDF--do the exporting


closemydocsavingno-- close the original file without saving

end tell

end if

end repeat

end tell

end proceed:


Pages to word


on open fs

my proceed:fs

end open


on proceed:fs

tell application "Finder"

repeat with i from 1 to (get count of items in fs)

if (name extension of item i of fs) is "pages" then

set MSWfile to text 1 thru -7 of (item i of fs as text) & ".docx"

tell application "Pages"

set mydoc to open (itemi of fs) -- open input file in Pages


exportmydoctofileMSWfileasMicrosoft Word--do the exporting


closemydocsavingno-- close the original file without saving

end tell

end if

end repeat

end tell

end proceed:

Sep 1, 2016 12:43 PM in response to stgrosso

Here is the way to do it, just drag and drop the files to convert on the script app, and it will export the converted files to the original location:

Pages to PDF:

on open fs

my proceed:fs

end open


on proceed:fs

tell application "Finder"

repeat with i from 1 to (get count of items in fs)

if (name extension of item i of fs) is "pages" then

set PDFfile to text 1 thru -7 of (item i of fs as text) & ".pdf"

tell application "Pages"

set mydoc to open (itemi of fs) -- open input file in Pages


exportmydoctofilePDFfileasPDF--do the exporting


closemydocsavingno-- close the original file without saving

end tell

end if

end repeat

end tell

end proceed:


PAGES to MS WORD


on open fs

my proceed:fs

end open


on proceed:fs

tell application "Finder"

repeat with i from 1 to (get count of items in fs)

if (name extension of item i of fs) is "pages" then

set MSWfile to text 1 thru -7 of (item i of fs as text) & ".docx"

tell application "Pages"

set mydoc to open (itemi of fs) -- open input file in Pages


exportmydoctofileMSWfileasMicrosoft Word--do the exporting


closemydocsavingno-- close the original file without saving

end tell

end if

end repeat

end tell

end proceed:

Batch convert Pages 5 files to PDF.

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