I have a "new file in folder" trigger on a script. Script is roughly:
get list of files in folder
verify the file name is correct for our purposes
email the file
wait 7 seconds (we recently added this to give users time to close the file so it won't be locked)
move the file from current folder to backup folder
As users drop files into this folder it seems possible to me that the script will be triggered multiple times and essentially overlap itself? Can that happen or does it check first to see if a prior triggered run is still running?
Thanks
can a script overlap itself from a folder trigger?
Moderators: Dorian (MJT support), JRL
Re: can a script overlap itself from a folder trigger?
Never used the trigger before so I did some experimenting. This is what I found.
First. The trigger didn't work when I pasted the path into the "Path" field. I had to use the provided browse button then select the folder from the browse window before the folder trigger would work.
Second. I made my script loop for 15 seconds. If I dropped two files in the folder in under 15 seconds the script would run once started by the first file then when the script was complete it would run a second time triggered by the second file. If I dropped more than two files in the folder in less than 15 seconds, the script would run once started by the first file then when the script was complete it would run a second time triggered by the other files but did not run a third time. Apparently if the script is started the trigger will recognize multiple new files as, there is a new file, and run one more time. Consequently, your script needs to recognize all new files in the folder and deal with all of them each time the script is triggered.
Hope this makes sense.
First. The trigger didn't work when I pasted the path into the "Path" field. I had to use the provided browse button then select the folder from the browse window before the folder trigger would work.
Second. I made my script loop for 15 seconds. If I dropped two files in the folder in under 15 seconds the script would run once started by the first file then when the script was complete it would run a second time triggered by the second file. If I dropped more than two files in the folder in less than 15 seconds, the script would run once started by the first file then when the script was complete it would run a second time triggered by the other files but did not run a third time. Apparently if the script is started the trigger will recognize multiple new files as, there is a new file, and run one more time. Consequently, your script needs to recognize all new files in the folder and deal with all of them each time the script is triggered.
Hope this makes sense.
Re: can a script overlap itself from a folder trigger?
Makes perfect sense, thanks!