Home Forums SQL Server 2008 SQL Server Newbies how to copy for a file in sub directories basing on the file name in ssis RE: how to copy for a file in sub directories basing on the file name in ssis

  • 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