Automator or script to batch convert pages to pdf files.
Hi,
I am trying to use this script Batch convert .pages to .pdf - Apple Community on Monterey Mac m1 and it is not working.
(*
Copy/paste into Script Editor, and save as Text (e.g. pages2PDF.applescript). Then,
option+Save As… and save as Application to the Desktop (pages2PDF.app). Drag and
drop one or multiple Pages documents or a folder containing Pages documents onto
the application, and the PDF will be written to the same location as the original.
Reference: https://discussions.apple.com/thread/7915966?answerId=31605574022#31605574022
Version:2.0, modified to fix hosting site command concatenation
Tested: macOS 11.2.3, Pages v10.3.9
VikingOSX, 2021-03-18, Apple Support Communities, No warranties expressed/implied.
*)
use scripting additions
property pages_kind : {"Pages Publication", "Pages Document"}
on open dropped_items
repeat with anItem in dropped_items
try
tell application "Finder" to set akind to kind of anItem
if akind contains "Folder" then
tell application "Finder"
set docList to (every item in entire contents of folder anItem whose kind is in pages_kind) as alias list
end tell
repeat with afile in docList
export_file(afile)
end repeat
else if akind is in pages_kind then
export_file(anItem)
end if
on error errmsg number errnbr
my error_handler(errnbr, errmsg)
tell application "Pages" to if it is running then quit
return
end try
end repeatend open
return
on export_file(theFile)
tell application "Finder" to set name_ext to name extension of theFile
set exportDocument to text 1 thru ((offset of name_ext in (theFile as text)) - 1) of (theFile as text) & "pdf"
-- Permissions error fix for Sierra < 10.12.4, and Pages v6, v6.0.5
close access (open for access exportDocument)
tell application "Pages"
try
set mydoc to open theFile
with timeout of 1200 seconds
if (version of it) ≥ "5.6" then
set export_quality to (Best as constant)
export mydoc to file exportDocument as PDF with properties {image quality:export_quality}
else
export mydoc to file exportDocument as PDF
end if
end timeout
close mydoc saving no
on error errmsg number errnbr
my error_handler(errnbr, errmsg)
tell application "Pages" to if it is running then quit
return
end try
end tell
tell application "Finder"
if exists (file exportDocument as alias) is true then
set extension hidden of (file exportDocument as alias) to false
end if
end tell returnend export_file
on error_handler(nbr, msg)
return display alert "[ " & nbr & " ] " & msg as critical giving up after 10end error_handler
Does anyone has an idea to fix this or have an automator ?
I have a lot of Pages files to convert to PDF any help is appreciated thanks !
MacBook Pro 13″, macOS 11.4