Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

.txt and .csv Expand / Collapse
Author
Message
Posted Thursday, May 02, 2013 10:46 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, March 10, 2014 10:37 AM
Points: 25, Visits: 325
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..
Post #1448915
Posted Thursday, May 02, 2013 11:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, March 19, 2014 6:05 AM
Points: 11, Visits: 282
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
Post #1448934
Posted Thursday, May 02, 2013 5:51 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1449017
Posted Friday, May 03, 2013 5:51 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 12:02 AM
Points: 4,828, Visits: 11,182
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1449154
Posted Friday, May 03, 2013 7:52 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, March 10, 2014 10:37 AM
Points: 25, Visits: 325

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
Post #1449209
Posted Friday, May 03, 2013 8:03 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 12:02 AM
Points: 4,828, Visits: 11,182
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1449219
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse