.txt and .csv

  • Hi,

    I was trying to get all my .txt and .csv files from one folder and move them to another folder so, how can i do that in foreach loop container i tried *.* as i has some more file types it is selecting all of them i need only .csv and .txt files can any of you guys help me in this..

  • Hi,

    Try adding .txt and .csv in the foreach loop editor.

    I am not sure whether both can be added at once, in that case you can actually take 2 foreach loop containers in your package and move the intended files only(.txt and .csv in your case).

    Refer below link(and similar links) for any further clarifications:

    http://www.sqlis.com/sqlis/post/Looping-over-files-with-the-Foreach-Loop.aspx

    Thanks,

    Chandra

  • You will need to loop over *.* but inside the loop you can setup a dummy Script Task that has no custom code in it just for the sake of being able to set a Precedence Constraint going to your first real Task inside the loop. Setup the Precedence Constraint to evaluate an Expression. In the Expression you'll test whether your filename variable ends with "txt" or "csv" and if so then proceed, else do nothing.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • SQL_Learning (5/2/2013)


    Hi,

    I was trying to get all my .txt and .csv files from one folder and move them to another folder so, how can i do that in foreach loop container i tried *.* as i has some more file types it is selecting all of them i need only .csv and .txt files can any of you guys help me in this..

    I am assuming that you are doing other things with these file and not just moving them?

    If not, the FEL is overkill (and potentially slow). Instead you could use Execute Process to issue a DOS MOVE command. Or use a Script Task to do the same in C#.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • I am assuming that you are doing other things with these file and not just moving them?

    If not, the FEL is overkill (and potentially slow). Instead you could use Execute Process to issue a DOS MOVE command. Or use a Script Task to do the same in C#.[/quote]

    Thanks all for your kind replies,

    Yes i was doing some more things. first i have to move all the .txt and .csv files into a sepatrate folder and then move them to their destination folders basic on the file names for which i am creating variable basing on the file name. but the thing is in execute process task

    Execute process task 1 --- i am selecting all the .txt files and moving them

    Execute process task 2 --- i am selecting all the .csv files and moving them

    both these go into the same folder is there any way that i can use a single Task to do this

  • SQL_Learning (5/3/2013)


    -- but the thing is in execute process task

    Execute process task 1 --- i am selecting all the .txt files and moving them

    Execute process task 2 --- i am selecting all the .csv files and moving them

    both these go into the same folder is there any way that i can use a single Task to do this

    Yes. Put your MOVE commands into a BAT file and call the BAT file from your EP task.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 6 posts - 1 through 5 (of 5 total)

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