Using Expressions in Filesystem task

  • Hi All,

    I want to know if there is a way to dyamically set Source and destination in a file system task.

    Eg I have a move a file from C:\ to D:\

    I will create variables

    sFileName - Holds name of file to be moved

    sfileExtension - Holda the extension of the file to be moved

    sFilePath - Holds present folder address of the file

    sDestinationPath- Holds the destination folder where the file has to be moved.

    I want to add datestamp before moving it.

    Presently i am using two more varaibles

    sSource = sFilePath + sFileName + sfileExtension

    sDestination = sDestinationPath + sFileName + DateStamp + SfileExtension.

    I would use a script task to set the above two variables and then use a File System Task with " Rename file" to move the file.

    However, i want to do away with that script task and two extra variables.

    I have checked the expressions in FileSystem. It has something called Source and Destination.

    I am trying to get my job done with these two.

    Is this possible? If so,how do i do it.

  • Hi All,

    I want to know if there is a way to dyamically set Source and destination in a file system task.

    Eg I have a move a file from C:\ to D:

    I will create variables

    sFileName - Holds name of file to be moved

    sfileExtension - Holda the extension of the file to be moved

    sFilePath - Holds present folder address of the file

    sDestinationPath- Holds the destination folder where the file has to be moved.

    I want to add datestamp before moving it.

    Presently i am using two more varaibles

    sSource = sFilePath + sFileName + sfileExtension

    sDestination = sDestinationPath + sFileName + DateStamp + SfileExtension.

    I would use a script task to set the above two variables and then use a File System Task with " Rename file" to move the file.

    However, i want to do away with that script task and two extra variables.

    I have checked the expressions in FileSystem. It has something called Source and Destination.

    I am trying to get my job done with these two.

    Is this possible? If so,how do i do it.

    You are going absolutely right direction. Let me tell u one thing u even don't need script task to set ur two variables sSource and sDestination. U can make these variables dynamic too.

    In the variables window select sSource variable and hit F4. this will open properties window for this variables (look @ ur corner right if properties is set up to appear there) then set Evaluate as expression to true and then build ur expression with aother variables u have defined like sFilePath + sFileName + sfileExtension DO same for sDestination. Now in the file system task put these variables accordindly and operation to rename file ( this will move and rename file) operation copy will create a copy and move and rename. move file oprtaion will fail.

    thsi will work absolutely fine.

  • I have done what you have said and it did work 🙂

    thank u very much. you rock

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply