Search code examples
c#sqlssisssis-2012

Processing Multiple files in multiple folders and archiving the folders using SSIS


I need to process the .txt files present in the below folder structure. I need to load all the *.txt files to a table. I have achieved that by using the SSIS foreach loop and checking "Traverse Subfolders" has loaded all the files to the table.

But the additional step i want to achieve here is rename and move the "SubfolderA" after the files are processed to "C:\MainFolder\Archive" path.

I know we can do this using the file system task for each file but i wanted to do this at the folder level.After each folder is processed move the folder to the archive folder.

C:\MainFolder

C:\MainFolder\Archive

C:\Main Folder\SubFolderA\

C:\Main Folder\SubFolderA\a.txt,b.txt,c.txt

C:\Main Folder\SubFolderB\

C:\Main Folder\SubFolderB\a.txt,b.txt,c.txt

C:\Main Folder\SubFolderC\

C:\Main Folder\SubFolderC\a.txt,b.txt,c.txt


Solution

  • What have you tried? I'll give you a hint: you'll need an outside 'for each folder' to go enumerate all folders and inside that you'll need a 'for each file' to process files in the folder. Once complete, you can move the folder. There is no for-each-folder enumerator but here is some workarounds: microsoft-ssis.blogspot.com.au/2011/01/… – Nick.McDermaid 17 hours ago