Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


BobJ
  •  BobJ
  • Paid support Topic Starter
2021-04-15T02:03:48Z
This should be so simple. All I'm trying to do is monitor a folder on a server for new files. When the new file trigger is fired, the file copy task runs. When there is only a single file to copy, it succeeds without error. If there are two or more files, the copy succeeds (and files are deleted from the source if specified), but I still get an "unsuccessful" completion message. The Output (Error) references "Exception in task: System.Exception: No Files(s) copied".

If in error handling, if i turn off "NoFilesCopied" and leave the others in place, the error doesn't appear, but what might I be losing by unchecking that option?

There is very little configured for this copy task - no file renames or anything else. What am I missing?
Sponsor
Forum information
thomas
2021-04-15T10:26:34Z
This i my guess:

You have a trigger monitoring a folder. Somebody drops two files there. The trigger fires twice, one for each file. This means your job runs twice. In your copy task, you copy all the files in the monitored folder. That means that in the first run, you copy all files, in the second run there are no files left to copy, and so you get an exception.

If my description is correct, you can solve it the way you have done it. Alternatively you can copy one file at the time. Think of each trigger-run as a loop over the files in the folder. Under variables - active job - triggers, you will have acces to the current file in the 'loop' . You can copy this single file, and at the end of the trigger loop all files will have been copied. Both approaches work.
Gary_W
2021-04-15T13:32:43Z
I had the same issue back in the day and Thomas nailed the reason why. Now For processing multiple files that could be dropped into a folder at the same time I don't loop, but have a "when file arrives" trigger and reference the file by {TRIGGER(Active|LastTrigger|File.Result.Name)} in the job. This way, if 2 files get dropped at the same time, the job just runs twice.

Depending on your tasks, this simple approach may work for you. this is not a one size fits all though, as I said, it depends on the tasks.
BobJ
  •  BobJ
  • Paid support Topic Starter
2021-04-15T15:55:44Z
Yep, you called it exactly! Been away from VC for awhile, and forgot about how file triggers work with one file versus multiple. The suggested solution - to use variable from the trigger solved my problem! Thank you.
bweston
2021-04-20T13:55:43Z
The advantage of operating only on the triggering file is that you have clearer flow control. The advantage of the other approach is that if you miss anything, such as because files got dropped while Visualcron wasn't running, you are already set up to process all files and can just run the job off schedule; if you're processing the specific triggering file, catching up if any have been missed may be less straightforward. I've used both approaches depending on the circumstances.
Support
2021-04-22T11:37:14Z
Originally Posted by: BobJ 

Yep, you called it exactly! Been away from VC for awhile, and forgot about how file triggers work with one file versus multiple. The suggested solution - to use variable from the trigger solved my problem! Thank you.



Like Gary said, the solution is the file trigger variable. Glad you got it working!
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
Scroll to Top