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

how to copy for a file in sub directories basing on the file name in ssis Expand / Collapse
Author
Message
Posted Tuesday, June 18, 2013 9:57 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 14, 2014 12:25 PM
Points: 25, Visits: 333
How to copy a particular file from sub folders basing on the file name. I have multiple sub folders and the file which i am looking for may present in the sub folder level or it may be present in another sub folders under the present sub folder. can any of you guys help me in this
Post #1464757
Posted Wednesday, June 19, 2013 10:08 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, January 17, 2014 12:26 PM
Points: 5, Visits: 41
My suggestion...
Drag a ForEach Loop container onto the Workflow tab
Drag a FileSystem task into the ForEach Loop container

Configure the ForEach Loop container as follows:
On the General tab...
- Name the task appropriately
On the Collection tab...
- Specify the Enumerator type...in your case "For Each File"
- Specify the (Parent) Folder path
- Provide the file name and extension attributes ( *.txt, myfile*.txt, etc)
- Specify how you want the file name returned. If you want to keep it simple then return the fully qualified file name which includes the file system path
- Specify if you want to search all subfolders
On the Variable Mapping tab..
- Click in the Variable box and select New Variable. Name it FQFileName.
- Set the data type to String
Exit Edit on the ForEach Loop Container

Configure the FileSystem task:
On the General tab...
- Set the Destination connection as needed...in your case it should be a folder...existing or create
- Specify whether to Overwrite or not
- Set the operation to Copy File
- Set the Is Source Path Variable to True
- Set the Source Variable to User::FQFileName from the dropdown list

When you execute the package it will find all files that match the source name pattern you provided in the folder structure you specified and copy them into the destination folder you specified.

HTH
MReed
Pragmatic Works
Post #1465277
Posted Wednesday, June 19, 2013 10:56 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 14, 2014 12:25 PM
Points: 25, Visits: 333
Thanks a lot for your help. Struggled for a day with this. But looks very simple and clear.
Post #1465293
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse