How to add Automator Folder Action from command line
See Attaching a Folder Action using Applescript for an AppleScript, an Open Scripting Architecture (OSA) language, solution. You can use osascript on the command line to run OSA scripts:


  Your syntax was OK in old versions (at least up to macOS 10.6.8). Since it has been depreciated and it must be replaced by "make" :

tell application "System Events"
    make new folder action at end of folder actions with properties {enabled:true, name:"FolderName", path:"path:to:my:folder}
    tell folder action "FolderName" to make new script at end of scripts with properties {name:"myScriptName.scpt"}
end tell