Tim Denison Tim Denison - 13 days ago 6
AppleScript Question

Use applescript to export files to pdf

I'm working on my first AppleScript (2.5) and can't seem to resolve my issue here.

I'm trying to open each markdown file in a folder and export to PDF. Opening the file with the specified application works, but I get 'The variable PDF is not defined' before the export happens.

I've tried four or five different sets of commands, from permutations on the save command to trying to use 'export' as some have suggested, but this form here appears to be the closest I've come to success. (Anytime I use export I get "Expected end of line, etc. but found identifier" and the word 'export' highlighted)

I appreciate any insight

tell application "Finder"
set sourceFolder to "Path:To:SourceFolder"
set MDFiles to files of folder sourceFolder whose name extension is "md"
end tell
repeat with f in MDFiles
set filePath to f as text
set newFilePath to (text 1 thru -2 of filePath) & "pdf"
tell application "MacDown"
open f
save f in file newFilePath as PDF
close f saving no
end tell
end repeat

Answer

After following @vadian's advice, it appears that the application does not have the ability to save to PDF.