1

I have a Foreach Loop Container that loops through files in a folder. I thought the Loop Container would only look at the files 1 time but apparently it will start back at the top and pick up a file that it had already seen again.

I have a script in my loop container that will process the file if it meets certain criteria. If it does not then it will simply skip the file.

The files that get processed are moved to another folder. The problem I am having is that once it goes through all the files it starts back up at the top of the list of files so it will just indefinitely continue to loop if there was a file that was skipped and not moved out to a different folder.

I know I can make it so that instead of skipping the file my process moves the file to another folder so that the foreach loop container can finish looping and the package can complete but I just thought I would double check first to see if there was a way of just having the loop container loop thru the files once so that if a file was already identified it would not be detected again by the loop container.

0

1 Answer 1

3

Based on clarification from the comments, the work flow was

C:\SourceFolder\File1.csv -> C:\SourceFolder\Archive\File1.csv

The ForEach File Enumerator has a Traverse Subfolder option which allows the enumerator to look beyond the top level of a folder hierarchy.

enter image description here

The specific mechanics of how the enumerator appears to be implemented is that it will identify all the elements within a folder. Process all files matching the FileSpec, *.csv is this case and then visit each directory applying the same pattern.

What you're observing was the original file was processed and correctly moved to the archive location. The archive location was then processed resulting in a double processed file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.