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 2, 2013 10:46 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, September 19, 2014 9:39 AM
Points: 25, Visits: 335
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 2, 2013 11:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, August 8, 2014 4:01 AM
Points: 13, Visits: 305
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 2, 2013 5:51 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:12 AM
Points: 7,135, Visits: 12,746
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
Post #1449017
Posted Friday, May 3, 2013 5:51 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 11:45 AM
Points: 5,254, Visits: 12,178
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 3, 2013 7:52 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, September 19, 2014 9:39 AM
Points: 25, Visits: 335

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 3, 2013 8:03 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 11:45 AM
Points: 5,254, Visits: 12,178
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