Yet another file stabler for Folder Actions

If you’re writing a folder action that handles big files copied from remote locations, use this as a template. The “stable(addedItems)” subroutine will make your script wait until all of the items have been received.

on adding folder items to theFolder after receiving addedItems
stable(addedItems)

-- The rest of your wonderful, wonderful script...

end adding folder items to

on stable(addedItems)
   tell application "Finder"
       repeat with theItem in addedItems
           -- Mr Comment sez : "Aare u Copieink teh Fileh?"
           repeat
               try
                   get info for theItem
                   set sizethen to (size of the result)
               on error theError -- Stuff went wrong, master
                   display dialog theError
                   error number -128 -- break it off if stuff went wrong!
               end try
               delay 5
               get info for theItem
               set sizenow to (size of the result)
               if sizethen = sizenow then
                   if sizenow = 0.0 then
                       error number -128 -- break it off if stuff went wrong!
                   end if
                   exit repeat
               end if
           end repeat
       end repeat --Waiting for all files to become stable
       
   end tell
   
end stable