on adding folder items to this_folder after receiving these_items
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
tell application "TextEdit"
activate
open this_item
delay 1
tell application "System Events"
click menu item "Export as PDF…" of menu 1 of menu bar item "File" of menu bar 1 of application process "TextEdit"
delay 1
key code 36
delay 1
key code 13 using command down
end tell
end tell
end repeat
end adding folder items to
This alternate version will quit TextEdit application after converting the files to .PDF. Be careful using this version because I set it to quit without saving any open documents if TextEdit was already running.
on adding folder items to this_folder after receiving these_items
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
tell application "TextEdit"
activate
open this_item
delay 1
tell application "System Events"
click menu item "Export as PDF…" of menu 1 of menu bar item "File" of menu bar 1 of application process "TextEdit"
delay 1
key code 36
delay 1
key code 13 using command down
end tell
end tell
end repeat
ignoring application responses
tell application "TextEdit" to quit without saving
end ignoring
end adding folder items to
If you save this following AppleScript in script editor as “Convert_To_PDF.scpt” in your /Users/INSERT YOUR USERNAME/Library/Workflows/Applications/Folder Actions folder. You don't need to use Automator at all. You simply need to control + click any folder you want as your “Hot Folder” and you will see this:
After you select “Folder Actions Setup”, you will see this:
Because you saved that AppleScript in your /Library/Workflows/Applications/Folder Actions folder, when you click the + sign to add a script to your folder for the folder action, it will automatically be available in the list of scripts to choose from
You may need to adjust the delay settings in the AppleScript code a little bit. Either way, this functions for me in the latest version of Sierra.