You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.
Is there a quick way to batch convert pages files into PDFs using Automator? I couldn't see anything obvious. thanks
Is there a quick way to batch convert pages files into PDFs using Automator? I couldn't see anything obvious. thanks
I don't think there are any helpful Pages actions, but you could use an AppleScript action to do the export.
Thanks for the reply Script is out of my comfort zone.
I found this droplet
but i'm getting "incompatible items" errors with the latest pages files. Anyone savvy around to troubleshoot?
on run
set theseItems to (choose fileof type with prompt "Choose the Pages documents to export to PDF:" with multiple selections allowed)
opentheseItems
end run
on opentheseItems
-- TRIGGERED WHEN USER DRAGS ITEMS ONTO THE DROPLET
set the filesToProcess to <>
-- filter the dragged-on items for presentation files
repeat with i from 1 to the count of theseItems
set thisItem to itemi of theseItems
if my checkForIdentifier(thisItem, ) is true then
set the end of the filesToProcess to thisItem
end if
end repeat
if filesToProcess is <> then
display alert "INCOMPATIBLE ITEMS" message "None of the items were Pages documents."
-- process the documents
my exportToPDF(filesToProcess)
end if
end open
on exportToPDF(theseFiles)
repeat with i from 1 to the count of theseFiles
set thisFile to itemi of theseFiles
set thisFilePOSIXPath to the POSIX path of thisFile
copy my deriveNewFilename(thisFilePOSIXPath, "pdf", "-", "") to
set targetFileReference to targetPOSIXpath as POSIX file
tell application "Pages"
with timeout of 1200 seconds
openthisFile
-- EXPORT THE DOCUMENT
with timeout of 1200 seconds
export front documenttotargetFileReferenceasPDF
end timeout
close front documentsavingno
end timeout
on error errorMessagenumbererrorNumber
if errorNumber is not -128 then
display alerterrorNumbermessageerrorMessage
end if
error number -128
end try
end tell
end repeat
end exportToPDF
on checkForIdentifier(thisItem, theseTypeIdentifiers)
-- uses Spotlight to check for specified item type
set the queryResult to ¬
(do shell script "mdls -raw -name kMDItemContentType " & ¬
quoted form of the POSIX path of thisItem)
if the queryResult is in theseTypeIdentifiers then
return true
return false
end if
on error
return false
end try
end checkForIdentifier
on deriveNewFilename(sourceItemPOSIXPath, newNameExtension, incrementSeparator, targetFolderPOSIXPath)
-- A sub-routine used for deriving the name and path of a new file using the name of an existing file
-- Pass in file ref in POSIX format, the new name extension, an increment separator, and any target directory (in POSIX format)
-- Name and POSIX path for new file are returned. The name is incremented if a file exists in the target location.
-- Pass a null string for the target directory to use the item's parent directory
-- Pass a null string for the new name extension to use the item's current name extension
copy my itemInfoFor(sourceItemPOSIXPath) to
if targetFolderPOSIXPath is "" then
-- get the path to parent folder of the source item
set targetFolderPOSIXPath to parentDirectoryPath
else if targetFolderPOSIXPath contains "~" then
set targetFolderPOSIXPath to (do shell script "echo " & targetFolderPOSIXPath)
end if
if targetFolderPOSIXPath does not end with "/" then set targetFolderPOSIXPath to targetFolderPOSIXPath & "/"
-- check file extension
if the sourceItemNameExtension is missing value then
set the sourceItemNameExtension to ""
if newNameExtension is "" then
set extensionSeparator to ""
set extensionSeparator to "."
end if
set extensionSeparator to "."
end if
-- generate the target file name
if the newNameExtension is "" then
set targetName to sourceItemName
set targetExtension to sourceItemNameExtension
set targetExtension to newNameExtension
set targetName to (the sourceItemBaseName & extensionSeparator & targetExtension) as Unicode text
end if
-- check to see if a file named the same as the source file exists in the target folder
set targetItemPOSIXPath to targetFolderPOSIXPath & targetName
set the fileExistenceStatus to ¬
(do shell script "[ -a " & (quoted form of targetItemPOSIXPath) & " ] && echo 'true' || echo 'false'") as boolean
if fileExistenceStatus is true then
set the nameIncrement to 1
-- create a new target path with the target item name incremented
set the newName to ¬
(the sourceItemBaseName & incrementSeparator & (nameIncrement as Unicode text) & extensionSeparator & targetExtension) as Unicode text
set targetItemPOSIXPath to targetFolderPOSIXPath & newName
set the fileExistenceStatus to ¬
(do shell script "[ -a " & (quoted form of targetItemPOSIXPath) & " ] && echo 'true' || echo 'false'") as boolean
if fileExistenceStatus is true then
set the nameIncrement to the nameIncrement + 1
set the targetPOSIXpath to (targetFolderPOSIXPath & newName)
end if
end repeat
set the targetPOSIXpath to (targetFolderPOSIXPath & targetName)
end if
end deriveNewFilename
on itemInfoFor(sourceItemPOSIXPath)
-- get the parent directory of the item
set the parentDirectoryPath to (do shell script "dirname " & (the quoted form of sourceItemPOSIXPath))
if parentDirectoryPath does not end with "/" then set parentDirectoryPath to parentDirectoryPath & "/"
-- get the name of the item
set the itemFileName to (do shell script "basename " & (quoted form of sourceItemPOSIXPath))
-- get the item name without extension
set the itemNameWithoutExtension to (do shell script "file=" & (quoted form of itemFileName) & ";echo $")
-- get the item extension
if itemFileName contains "." then
set the itemFileExtension to do shell script "file=" & (quoted form of itemFileName) & ";echo $"
set the itemFileExtension to missing value