August 27, 2015 at 9:36 pm
Hi Friends,
I am trying to loop a file through a dynamic folder. ForEach Loop must process only the specified file that we are passing through the variable. It needs to process even the file exists in a child folder. I am able to process all the files in parent as well as in sub folders but not able to do the same with one specific file. How can I do this?
Please advise me on this. Any suggestions would be appreciated.
Thanks,
Charmer
August 27, 2015 at 11:39 pm
http://enabledbusinesssolutions.com/blog/ssis-starter-kit-for-the-uninitiated-foreachloop/
August 28, 2015 at 1:00 am
Hi Jayanth,
The URL tells us how to do looping in the directory by dynamic path....but I also need dynamic file . Like it should process only the file that I pass in the variable "User::FileName".
Thanks,
Charmer
August 28, 2015 at 1:30 am
Use your favourite scripting language to find the path to the file. For example, in a simple command prompt, you can do it like this:
dir x:\MyTopLevelFolder\MyFile.ext /s
John
August 28, 2015 at 1:39 am
Hi John,
We know the path of the file. But I want to process only the file that I pass instead of processing all the files in the folder.
In the foreach container
for eg: if I pass variables [User:FilePath] = "C:\User\UserName\Desktop"
and [User::filename] = "A" and [User::FileSpec] = ".dtsx"
it should process only this file.
If no value is passed to file name, then It should process all the files in the folder.
Thanks,
Charmer
August 28, 2015 at 2:11 am
If you will definitely only have one file or all files to process, have two separate tasks: one a loop, and the other a simple processing of the single file. You can use precedence constraints to determine which one to execute.
If, on the other hand, you have multiple files, each one of which may or may not be processed. Have a loop, and determine within that loop whether each file should be processed, using a precedence constraint to execute or not execute the task that does the actual processing.
John
August 28, 2015 at 3:47 am
I thought of making two containers like you said determine using constraints. I was not sure of it if this is the only method or we still can be able to achieve with one container itself.
So I was looking for advise that I got from you.
Thank you, John.
Thanks,
Charmer
August 28, 2015 at 4:14 am
Another option, if you know in advance which files you need to process, is to get them all into an ADO result set and loop through them with a For Loop (instead of a Foreach Loop).
John
August 28, 2015 at 6:04 am
okay..Thank you John. I really appreciate your help
Thanks,
Charmer
August 28, 2015 at 7:08 am
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply