Reputation: 251
Given two flat files a and b, I want to copy these files from source to destination.
Can I move two files by using SSIS file System Task component?
If I need to do this through use of the 'Foreach Loop Container' inside that File system Task, How I can proceed?
Upvotes: 3
Views: 47079
Reputation: 655
You can most definitely move the files from source to destination using the file system task.
Add the Foreach Loop Container to your workspace, and then the File System Task within it.
Create a variable in which to store your filenames.
Edit the Foreach loop first, select Collection from the left menu and then enter your Directory in the Folder space under Enumerator Configuration. For files, either keep the default if you are to move all files or add a mask if you wish to be selective.
Select the Variable Mappings tab from the left menu and then in the right menu, select the variable you defined to hold your filename from the first step and enter 0 in the Index field.
On the File System task, you will need to define a destination connection representing your destination directory, select the appropriate operation, and then change IsSourcePathVariable to true and select the SourceVariable from step 1.
The benefit of this method over the methods such as COPY C:\YourSource*.TXT C:\YourDestination is that it is much easier to automate this step among a series of tasks and workflows, using the created variables and components.
Upvotes: 5
Reputation: 19184
You can mess about with for loops etc. or you can just run
COPY C:\YourSource\*.TXT C:\YourDestination
In an execute process task
(or something along those lines depending on exactly what you want)
Upvotes: 2
Reputation: 13141
You to set following in Foreach Loop Containter
:
In Collection
menu pick Foreach File Enumerator
, choose you folder and file filter if you need to. In Variable Mappings
menu choose a string variable and assing 0 index.
Then place File System Task
in foreach, and use the variable to move files. You'd probably need two more variables: one for directory path (you can also use it in foreach), and fullpath variable that will combine via Expression
directory path variable with filename variable that you get from foreach.
Upvotes: 1