Attaching folder actions to new folders

Hi

I am currently writing a script that requires that I generate a hot folders.

My questions are:

Does the action script for the hot folder need to be housed in the “Folder Action Script folder” do can it be elsewhere?

Can the script be attached programmatically? (i think it can)

If so, can I use it to called subroutines within the main script rather than have a complete standalone action script that is separate from the main script that created the folder in the first place? I was hoping that the action script would be a simple action that runs the main script again when an item is placed in the hot folder, sending it a couple of variables like the file name etc.

Any thoughts would be appreciated.

Tim

I extracted the relevant instructions from an Apple sample script :

set targetFolder to (path to desktop folder as text) & "target:"

tell application "System Events"
   set folderName to name of folder targetFolder
   if not (exists folder action folderName) then
       make new folder action at end of every folder action with properties {path:targetFolder}
   end if
   # The script to attach is supposed to be stored
   # in (path to library folder from local domain as text) & "Scripts:Folder Action Scripts:"
   # or
   # in (path to library folder from user domain as text) & "Scripts:Folder Action Scripts:"
   make new script at end of every script of folder action folderName with properties {name:"Image - fixed 800x600.scpt"} # edit to fit your needs
end tell

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) lundi 29 mai 2017 13:10:31