I'm still very much at the bottom of the learning curve for Automotor and AppleScript so I apologise for lack of basic understanding that has inevitably led to this question.
I'm running MacOSX 10.15.6 (Catalina) on a MacBook Air. My ultimate aim is to take a folder of .pages files (or other compatible file types) and batch convert to .pdf (or other) by opening with Pages and then exporting to the same folder as new file type. I have set up an Automator script that contains: i. Get Specified Finder Items - defines folder containing the files ii. Get Folder Contents - lists all documents in folder iii. AppleScript to open each document and export as PDF
Even before getting to the 'export' bit (I've commented out the export command in the bit below), the AppleScript is throwing an error when I try to get the path to the directory containing the file. The AppleScript looks like:
on run {input, parameters}
repeat with theFile in input
tell application "Pages"
set theDoc to open theFile
set theDocName to name of theDoc
set theName to (characters 1 thru -7 of theDocName) as text
set thePDFPath to ((path to theFile as text) & theName & ".pdf") as text
-- export theDoc to thePDFPath as PDF
close theDoc
end tell
end repeat
end run
The error I get is:
The action “Run AppleScript” encountered an error: “Pages got an error: Can’t make alias "path:to:directory:test.pages" into type constant.”
I've been struggling with this for a while and none of the suggestions I've found online so far have helped to resolve the issue. Any help would be very much appreciated.