Loop between folders and capture foldername
situation where Folder names 02-22-2010 01-21-2010 .... ..... 09-03-2010 I have lot of " .txt" files inside each folder. I did a foreach loop for one folder and files within that folder and read files to DB. Now, I want to know how can we loop between the folders and capture the folder name into a variable. Is there a functionality in FOREACH loop to do this or else any other way we can accomplish this.
May 16th, 2011 10:24am

One way: get it with DIR from Command Prompt. The following article has a script to get the names of subfolders in a folder and upload it to a table: http://sqlusa.com/bestpractices2005/notepad/ Once you have the subfolder names in a table, you can proceed programmatically to process the content of each subfolder with Foreach loop. With xp_dirtree you can get the hierarchical directory(folder) structure from a specified parent directory (demo in link). Kalman Toth, SQL Server & BI Training; SQL 2008 GRAND SLAM
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 11:04am

check these one: http://microsoft-ssis.blogspot.com/2011/01/foreach-folder-enumerator.htmllatha
May 16th, 2011 11:05am

try this: http://microsoft-ssis.blogspot.com/2011/01/foreach-folder-enumerator.html sorry double post of URL Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 12:28pm

you can fetch folder names with script task ( C# or VB.NET ) and get folder names into an array, then in a foreach loop loops through this array and inside it add another foreach loop which loops through each item of array ( you should use expression to set soruce folder for inner foreach loop ) let me know where you need more details.http://www.rad.pasfu.com
May 16th, 2011 12:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics