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.
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.
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.
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
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
Hi,
can you help me with this, please?
The script works very well. Just I want to export the file automatically to the same path file without to be asked for. I mean: I need to export all my pages files to docx and I want the destination folder to be the path folder. Thanks. S.
I think that would require more sophisticated understanding of AppleScript than I currently have.
Just choose the the same folder at the second dialogue and it will output there without problem.
I would but I've 664 files to convert. I just would find them in the Finder and past to the apps.. but I need to convert everything to the own destination path.
I know the feeling. I went through folders individually myself.
The website I used to understand more about applescript was this one: https://iworkautomation.com
It seems to list most of the applescript commands, which is how I managed to adapt the script to convert to word format. There might be something there that manages file paths a bit better.
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
Thank you so much! You help me a lot with this, i'm trying to use my docs (formerly Pages docs) into a many cloud services.
Thank you!
You're a life saver. Just converted like 200 pages docs in about 1 minute. 😎
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 🙂
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:
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:
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:
I have posted a drag & drop Pages to PDF solution this morning. It expects at least Pages v5.5 with support for Yosemite and El Capitan.
Batch convert Pages 5 files to PDF.