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.
To exclude directories, use the File parameter and omit the Directory parameter, or use the Attributes parameter. To get directories, use the Directory parameter, its "ad" alias, or the Directory attribute of the Attributes parameter.
gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.
Go to Start > Settings > Update & Security > Windows Security > Virus & threat protection. Under Virus & threat protection settings, select Manage settings, and then under Exclusions, select Add or remove exclusions. Select Add an exclusion, and then select from files, folders, file types, or process.
Repository exclude - For local files that do not need to be shared, you just add the file pattern or directory to the file . git/info/exclude . Theses rules are not committed, so they are not seen by other users.
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 type System.Object
(Scope: Package)
Execute Script Task
before the for each Loop container and add User::FilesList
as a ReadWrite Variable
In the Script Write The following Code:
Imports System.Linq
Imports System.IO
Imports System.Collections.Generic
Public Sub Main()
Dim Directory as String = "C\Temp"
Dim strSubDirectory as String = Directory & "\New Folder"
Dim lstFiles As New List(Of String)
lstFiles.AddRange(Directory.GetFiles(Directory, "*.*", SearchOption.TopDirectoryOnly).Where(Function(x) Not x.Contains(strSubDirectory)).ToList)
Dts.Variables.Item("FilesList").Value = lstFiles
Dts.TaskResult = ScriptResults.Success
End Sub
In the For each Loop Container Choose the Enumertaion Type as From variable Enumerator
and choose FilesList
variable as a source
ScreenShots
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With