SSIS 2012 Rename File by appending Date

  • I have a foreach container that processes zero or more similarly-named csv files, then moves each file to an archive folder. I want to append (or prepend) the date to the filename upon moving it to the archive folder, but can't quite figure out how to do that with the "move" function of the File System Task. What's the strategy?

    I have variables for the ImportFolder (path), the FullyQualifiedFileName of the csv file (UNC)....

    Jim

  • I usually handle this with a script task. In C# it would be something like...

    File.Move(Dts.Variables["User::FullyQualifiedFileName"].Value.ToString(), Dts.Variables["User::FullyQualifiedFileName"].Value.ToString().Replace(".csv", DateTime.Now.ToString() + ".csv");

  • I found a fairly simple approach here, but I also like your script task. I'll look into script so I can learn more...after I get this package done. Thank you!

    Jim

  • you need to use the expressions (left hand pane in the editor window) and create a formula that appends the date before the file extension. I don't have SSIS to hand at this present time, if you struggle post back and I will get you some sample code.

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

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