I am posting this for the noobies and the non-programmers who frequent this forum to possibly save you the time and frustration that I just went through to find out something so simple, so maddeningly stupid that I am almost too ashamed to admit it happened to me. Almost but not quite (I have little shame).
Okay, the script below is pretty simple, it’s function is to add an inbox and an outbox to a customers folder (via duplication so I can keep that swell custom icon on them) in my FTP directory then attach a script to each of those folders. Really simple, except it wasn’t. I knew to put the script that I wanted to attach to the FTP folder (the one below) and the scripts to be attached to the inbox and outbox respectively in the Folder Action Scripts folder so they actually run (thanks Stefan) But here’s what I didn’t know - the scripts need to have the .scpt extension at the end in order to run. After re-writing my script two dozen times I finally started looking at the properties of the script, I mean what else was left? I noticed that when I right-clicked the FTP folder the context menu did not have either the Remove a folder action> or the Add a folder action> entry but when I did the same to a folder I knew worked properly I saw that the ONLY difference was that the script had the .scpt extension.
Now maybe I’m wrong and this is just a fallacious assumption on my part, and I hope that one of the regulars will correct me if that is the case, but this solved my problem. I never thought that I’d have to pay attention to the extensions of any of my files on a Mac, but I guess this is the exception to that rule.
on adding folder items to this_folder after receiving added_items tell application "Finder" activate set lFTPFolder to this_folder as Unicode text set lCustomerFolder to added_items as Unicode text set lDMTFolder to ((path to applications folder) & "Application Folder Name:") as Unicode text my sDuplicateFolder(lCustomerFolder, lDMTFolder, "Inbox") my sDuplicateFolder(lCustomerFolder, lDMTFolder, "Outbox") my sAttachScripts(lCustomerFolder, "Inbox") my sAttachScripts(lCustomerFolder, "Outbox") end tell end adding folder items to --> Duplicate folder on sDuplicateFolder(lCustomerFolder, lDMTFolder, lBox) tell application "Finder" try set lBoxPath to (lDMTFolder & "Components:Folders:" & lBox) as Unicode text duplicate lBoxPath to lCustomerFolder on error msg display dialog "ERROR: " & msg with icon stop end try end tell end sDuplicateFolder --> Attach script to folder on sAttachScripts(lCustomerFolder, lBox) tell application "System Events" try attach action to (lCustomerFolder & lBox) as Unicode text using lBox & ".scpt" on error msg display dialog "ERROR: " & msg with icon stop end try end tell end sAttachScripts
Hope this saves someone else some headaches.