I got a package that runs through a folder and it's sub folders to get client data. The agreement has changed and now the client will post his data in different folder name every time. I was wondering if I can do a foreach loop on the main folder and exclude specific folders like archive
.
I don't have knowledge in writing scripts so I was wondering if SSIS can do that without the script.
You can't do this in the foreach loop properties, but what you can do is start the tasks inside the loop with a script task that checks to see if the folder name is a value that you want to exclude, and if it is, do nothing but loop to the next folder.
you may have a more control, if you use Script task
Here is the sample code which I have used in one of SSIS:
Using Execute Script Task
Get List of - filtered - files using an
Execute Script Task
before entering Loop and loop over then using ForEach Loop container (Ado enumerator)User::FilesList
) with typeSystem.Object
(Scope: Package)Execute Script Task
before the for each Loop container and addUser::FilesList
as a ReadWrite VariableIn the Script Write The following Code:
In the For each Loop Container Choose the Enumertaion Type as
From variable Enumerator
and chooseFilesList
variable as a sourceScreenShots
Using Expression Task
For more details you can refer to my answer in the following link (it is a similar case) WildCards in SSIS Collection {not include} name xlsx
I would achieve this (without a Script Task) by setting the Disable property on the Tasks within the For Each Loop Container using an Expression, e.g.