Add an AppleScript Folder Action to a Selected Folder

Hi there,
I want to find a workflow for a kind of a watchfolder.
I have a given folder structures where from time to time comes new files from another department to a subfolder. And I want to add the applescript "add - new item alert.scpt" from the default /Library/Scripts/Folder Action Scripts to that folder.

The workaround would be selected the parent folder find the subfolder and add the "add - new item alert.scpt" -Script.

I have tried to dive deeper into applescript and ended up with this

set posixPath to "/Users/smap/Desktop/xxxx/yyy/07_Derivate"
set targetFolder to POSIX file posixPath as text

set posixScriptPath to "/Library/Scripts/Folder Action Scripts/add - new item alert.scpt"
set thisScript to POSIX file posixScriptPath as text

tell application "System Events"
make new folder action at end of folder actions with properties {enabled:true, name:"02_Screener", path:targetFolder}
tell folder action "02_Screener" to make new script at end of scripts with properties {name:thisScript}
end tell

But it did not work. I thought mybe it would be easer to automate it with KM and work with images and mouse clicks but I can´t figure it out how to emulate a right mouse click to get to the context menu and also how to select my specific folder.

So far I can navigate to the subfolder.
From there I want to select the folder which gets the folder action.
So my thought was to Right click and add the folder action I want.

Can someone help me out here?

Best Stefan

2 Likes