Folder Action Strategies and Limitations

I have some questions/issues regarding folder actions that I’m hoping someone here can help me with.

Issue #1:

I’ve got two folders that have (different/distinct) folder actions attached to them.

If files are dropped into both the folders, it appears that only one of the folder action scripts are activated – and it appears to be indeterminate as to which one launches.

Issue #2:

How quickly can new files be dropped into a “folder action” activated folder? It appears that if I drop files into a folder too quickly, not all the items make it to the folder action. Is there anyway to control this or compensate for this?

Issue #3:

Is there a good mechanism that would allow a folder action script to be quick about processing the items dropped into a folder and then pass them on to another script or app for more lengthy processing. IOW, I’d like the folder action script to quickly return to it’s “dormant” mode waiting for the next item to arrive while allowing some other script or app to deal with the more length processing of the data of the file.

Issue #4:

I thought properties, at the highest scope of a script, were persistent. However, it seems that everytime a folder action script is launched, the top-level properties return to default values.

Thanks for any light you can shed on these issues. I hope these questions make sense.

– Mark

P.S. I did search the archives for similar questions, but did not find anything else. If there is a discussion already, please point me to it. Thanks!

Some of my observations int he wonderful world of folder actions:

Re Issue #1:

Haven’t run into that one yet.

Re Issue #2:

If your script is sufficiently brief and your machine reasonably fast, the system should be able to keep up with a human being dragging files by hand. If not all items are “showing up”, you may not be properly handling the possibility of multiple files appearing at once. Remember that “addedItems” is a list.

Re Issue #3:

The best way I’ve found to keep folder actions happy is to have a very basic core routine, with subroutines to do all the heavy lifting. This is the only way I’ve been able to get around things like scripts firing a second time when an item is renamed, etc.

Re Issue #4:

Properties should be retained, but can be lost if a script crashes for any reason. Folder Actions are tricky to troubleshoot, so if you use a lot of “try” routines like I do, you may be getting errors and not even know it. The script may just stop part way through, or appear to not run at all.

My biggest issue with folder actions is the multiple-run thing. I had always assumed that the script would run through completely and independently for each new item added to a folder, for example. It turns out the script will fire for item #1, then start again at the beginning for item #2 while item #1 was still being processed by the same instance of the script! You can imagine the havoc this creates when variables being used later in the script are reset to their default values by the second firing. This is another reason to use subroutines for the bulk of the work, and have the core script filter out things like renamed files that shouldn’t be processed.

I too would like to hear others’ experiences with folder actions.

Vic