can a script overlap itself from a folder trigger?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
howl
Junior Coder
Posts: 24
Joined: Tue May 29, 2007 6:41 pm

can a script overlap itself from a folder trigger?

Post by howl » Mon Feb 01, 2016 9:49 pm

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

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: can a script overlap itself from a folder trigger?

Post by JRL » Wed Feb 03, 2016 5:15 pm

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.

howl
Junior Coder
Posts: 24
Joined: Tue May 29, 2007 6:41 pm

Re: can a script overlap itself from a folder trigger?

Post by howl » Tue Feb 09, 2016 10:11 pm

Makes perfect sense, thanks!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts