SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


.txt and .csv


.txt and .csv

Author
Message
SQL_Buddy99
SQL_Buddy99
SSC-Enthusiastic
SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)

Group: General Forum Members
Points: 126 Visits: 398
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..
SatishChandra_SQL
SatishChandra_SQL
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 359
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
Orlando Colamatteo
Orlando Colamatteo
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40860 Visits: 14413
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
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)

Group: General Forum Members
Points: 52948 Visits: 21195
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#.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
SQL_Buddy99
SQL_Buddy99
SSC-Enthusiastic
SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)SSC-Enthusiastic (126 reputation)

Group: General Forum Members
Points: 126 Visits: 398
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
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)

Group: General Forum Members
Points: 52948 Visits: 21195
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.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search