• Hello all,

    There is a simpler way I think for providing the new filename that you want to rename your files to wihtout the need for a connection manager or arcane .NET scripts:

    - Assuming you put your task inside a ForEachLoop with a Collection of type ForEachFileEnumerator which maps a Variable [User::FileName] for the current filename of each file:

    On the FileSystemTask Properties do this:

    1. SourceConnection Section: IsSourcePathVariable = TRUE, SourceVariable = User::FileName ( This is the variable you get from the ForEachLoop Container)

    2. DestinationConnection: IsSourcePathVariable = TRUE, DestinationVariable = User::NewFileName ( I just made this up, use whatever name you like)

    Now the fun part:

    - Each variable can be replaced by an Expression exactly as you do with various Properties of Tasks andTransformations. Here's how:

    1. Open the Variables Window and Click on the User::NerFileName Variable. ( NOTE: YOu must have the FileSystemTask selected in the Control Flow since the Variables Window refreshes with each selection to show only Variables that are in scope).

    2. An alternative way to Click on that variable is via the Tree in the Package Explorer Tab. Find the node of your FileSystemTask and expand it to see its Variables subfolder.

    3. Assuming you have clicked on the Variable with one of the two methods above, try looking inside the Properties window. It is usually docked on the bottom right part of the IDE. These are the Properties of the Variable you have selected. Nifty heh?

    4. Now do this: EvaluateAsExpression = TRUE.

    5. Now give the Expression to the next Property named Expression.

    6. Here is a sample Expression for a Timestamp which assumes a .dat extension. Customise it as you like:

    REPLACE( @[User::FileName] , ".dat", "_" + (DT_WSTR, 4) YEAR( @[System::StartTime]) + "_" + (DT_WSTR, 2) MONTH( @[System::StartTime]) + "_" + (DT_WSTR, 2) DAY( @[System::StartTime]) + ".dat" )

    That's all. No connection manager needed. No need to use PAckage Configurations also. Just a variable. When SSIS wants to use it is evaluates the Expression. All the other Variables that the Expression Uses are in Scope. User::Filename belongs to the FileSystemTask's parent Container (the ForEachLoop COntainer) and the System::StartTime belongs to the Package.

    Regards,

    ArthurDent