How to batch convert .pages to .pdf with automator & applescript
Hi all,
As the title states, I want to drag and drop one (or a whole stack) of .pages documents onto an automator app, and have it pump out .pdfs...
Here is my code, it crashes with an error, but I'm really new to this so I don't really know what's going wrong.
on run {input, parameters}
tell application "Finder"
repeat with aFile in input
if class of (itemaFile) is not folder then
set {tName, fileExt} to {name, name extension} of aFile
if fileExt is not missing value and fileExt is not "" then
set tName to "PDFs/" & (text 1 thru -((countfileExt) + 2) of tName) & ".pdf"
tell (get container of aFile)
if not (existsfolder "PDFs") then makenewfolderat it with properties {name:"PDFs"}
tell application "Pages"
set mydoc to openfileaFile-- open input file in Pages
exportmydoctofiletNameasPDF--do the exporting
closemydocsavingno-- close the original file without saving
end tell
end tell
end if
end if
end repeat
end tell
end run