Skip to content

Instantly share code, notes, and snippets.

@SpacyRicochet
Created January 20, 2017 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpacyRicochet/04f72e5191c64bdce4bc99ac0eb27ed5 to your computer and use it in GitHub Desktop.
Save SpacyRicochet/04f72e5191c64bdce4bc99ac0eb27ed5 to your computer and use it in GitHub Desktop.
Apple Script that _should_ export all selected .pages documents to PDF. Doesn't work due to Sandboxing.
on run {input, parameters}
repeat with _document in input
tell application "Finder"
set _directory to get container of file _document
set _documentName to name of _document
if _documentName ends with ".pages" then ¬
set _documentName to text 1 thru -7 of _documentName
set _PDFName to _documentName & ".pdf"
set _incrementIndex to 1
repeat until not (exists file _PDFName of _directory)
set _PDFName to ¬
_documentName & "-" & (_incrementIndex as string) & ".pdf"
set _incrementIndex to _incrementIndex + 1
end repeat
set _location to (_directory as string) & _PDFName
end tell
tell application "Pages"
activate
open _document
with timeout of 1200 seconds
export front document to file _location as PDF
end timeout
close front document
end tell
end repeat
return input
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment