Folder Action script times out or can't process certain amount?

I’ve attached a folder action script to a folder I found here:

Here’s the script:

on adding folder items to this_folder after receiving these_items

    tell application "Finder"

        if not (exists folder "Done" of this_folder) then

            make new folder at this_folder with properties {name:"Done"}

        end if

        set the destination_folder to folder "Done" of this_folder as alias

        set the destination_directory to POSIX path of the destination_folder

    end tell

    repeat with i from 1 to number of items in these_items

        set this_item to item i of these_items

        set the item_info to info for this_item

        if this_item is not the destination_folder and ¬

            the name extension of the item_info is not in {"zip", "sit"} then

            set the item_path to the quoted form of the POSIX path of this_item

            set the destination_path to the quoted form of ¬

                (destination_directory & (name of the item_info) & ".zip")

            do shell script ("/usr/bin/ditto -c -k -rsrc --keepParent " ¬

                & item_path & " " & destination_path)

        end if

    end repeat

end adding folder items to

it runs fine as long as I only move like 8 or 10 files into the folder. But I have hundreds. If I drop all of them on it starts but then just stops after a while. I tried dropping like 20 just so I knew I wasn’t being impatient. Is there a memory limit or time limit for scripts and a way to override such things if they exisit? Thanks!

It’s not a good idea for a folder action script to change items in the folder that it is watching. What happens is that every time the script makes a change, the script gets called again, causing a second instance of the script to run while the first one continues. With a small number of files, this may or may not be a problem, but when you drop a large number in, the system can be overwhelmed.

nailed it - thanks. And, uh… thanks, er… “Applescript Language Guide…”