Last active
October 1, 2021 09:54
-
-
Save yannbolliger/a09cb714429b0dcf28d7d3256de8d993 to your computer and use it in GitHub Desktop.
Export pages to pdf with Apple Script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript | |
on run argv | |
set script_folder to (POSIX path of ((path to me as text) & "::")) | |
set this_folder to (script_folder & (item 1 of argv)) | |
tell application "System Events" | |
set these_files to files of folder this_folder whose name extension is "pages" | |
end tell | |
repeat with this_file in these_files | |
set file_name to name of this_file | |
set the_folder to this_folder as POSIX file | |
set lean_file to text 1 thru ((offset of "." in file_name) -1) of file_name & ".pdf" | |
set out_file to (the_folder as Unicode text) & (lean_file) | |
set in_file to (the_folder as Unicode text) & (file_name) | |
tell application "Pages" | |
set mydoc to open file in_file | |
export mydoc to file out_file as PDF | |
close mydoc saving no | |
end tell | |
end repeat | |
tell application "Pages" | |
quit saving no | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All credits go to https://gist.github.com/loop/7207134ed7ff7a288ee1.
This is simply the version that takes the relative path to folder containing .pages documents and exports all of them to pdfs.
Run with
./export_pdf.applescript path/to/folder_containing_pages