SSIS Move FIle Task and Rename

Larry Brister
Larry Brister used Ask the Experts™
on
I have a file task that moves a file (variable) fro  Inbound folder to a processed folder

I would like to also rename that file in the process to the same filename.csv to filename_yyyyMMddmmss.csv
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Technical Architect, Capgemini India
Commented:
Hello!

This can be done by using a ForEach Iterator to iterate through the files and the "File System Task" with a "Rename File" configuration to perform the rename and/or file move once the processing is complete. You can look at the details in my post here: https://nakulvachhrajani.com/2016/11/28/0395-sql-server-ssis-adding-date-and-time-to-a-file-name-after-processing/

In summary, you will need a variable to build the new file name with a string similar to the one below (which is for yyyyMMdd, but you can extend it for mmss as well):
SUBSTRING(@[User::FileName], 1, FINDSTRING(@[User::FileName],".",1) -1 ) + (DT_WSTR,4)YEAR(GETDATE()) + (DT_WSTR,2)MONTH(GETDATE()) + (DT_WSTR,2)DAY(GETDATE())

Open in new window

Larry Bristersr. Developer

Author

Commented:
Perfect. Thanks
Nakul VachhrajaniTechnical Architect, Capgemini India

Commented:
Glad that I could be of help. Thanks the grade! :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial