Folgendes Script funktioniert bei mir - OSX 10.13.6
Das Fehlerhandling kann noch ausgebaut werden, und der Bereich unten ist nur eine Anregung wie man weiter arbeiten könnte.
Einige Anregungen kamen von https://forum.latenightsw.com/t/folder-action-setup-triggering-the-script/765
Grüße,
Dirk
tell application "Finder"
set theFolder to folder "folderaction" of desktop
set theFolderPath to POSIX path of (theFolder as alias)
-- strip trailing "/"
set theFolderPath to text 1 thru -2 of theFolderPath
set theScript to file "folderaction.scpt" of desktop
set theScriptPath to POSIX path of (theScript as alias)
end tell
-- tell application "Folder Actions Setup"
tell application "System Events"
try
set theAction to make new folder action with properties {path:theFolderPath}
on error
-- "whose" does not work:
-- set theAction to folder action whose path is theFolderPath
repeat with fa in folder actions
if path of fa is theFolderPath then set theAction to fa
end repeat
end try
tell theAction
try
set theActionScript to make new script with properties {POSIX path:theScriptPath}
on error
repeat with fas in scripts
if POSIX path of fas is theScriptPath then set theActionScript to fas
end repeat
end try
end tell
-- access properties
get properties of theAction
set enabled of theAction to false
get properties of theActionScript
set enabled of theActionScript to false
end tell