How to loop the dynamic file name?

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • okay..Thank you John. I really appreciate your help

    Thanks,
    Charmer

  • the link contained the blog series , with steps to do file looping as well as dybamically change the file path for source connection. In fact there is a youtube video link in there as well. It might be better to read the blog fully .

    Jayanth Kurup[/url]

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply