Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude specific Sub Folders

Tags:

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.

like image 241
Mustafa Alani Avatar asked Apr 07 '17 16:04

Mustafa Alani


People also ask

How do I exclude a subfolder in powershell?

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.

Does Gitignore work in subfolders?

gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.

How do you exclude a directory?

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.

How do I exclude a directory in git?

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.


1 Answers

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)

  1. You have to a a SSIS variable (ex: User::FilesList) with type System.Object (Scope: Package)
  2. Add an Execute Script Task before the for each Loop container and add User::FilesList as a ReadWrite Variable
  3. 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
    
  4. In the For each Loop Container Choose the Enumertaion Type as From variable Enumerator and choose FilesList variable as a source

ScreenShots

enter image description here

enter image description here

enter image description here

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

like image 169
Hadi Avatar answered Sep 25 '22 10:09

Hadi