question

OanaMihai-6838 avatar image
0 Votes"
OanaMihai-6838 asked ZoeHui-MSFT commented

SSIS - rename file with file system task - capture name of renamed file

Hello,

I have a SSIS package which copies a file and renames it, adding the date and time in the name. I need to save this generated new name in order to use the file for data export. Is there a way of capturing the generated name from the File System task?

Thank you.

sql-server-integration-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ZoeHui-MSFT avatar image
0 Votes"
ZoeHui-MSFT answered ZoeHui-MSFT commented

Hi @OanaMihai-6838,

Use a File System Task Editor with Rename File operation. The picture below, I have a variable called 'Variable1', with a value like C:/Users/MyUser/Desktop/1.txt.

61.txt is a "File Connection Manager" with "Create File" operation.

Go to its properties and add a ConnectionString expression with:

REPLACE(@[User::Variable1],".txt","")+""+(DT_WSTR, 04) YEAR( GETDATE() )+(MONTH(GETDATE())>=10 ? (DT_WSTR, 02)MONTH(GETDATE()): "0"+(DT_WSTR, 02)MONTH(GETDATE()))+ (DAY(GETDATE())>=10? (DT_WSTR, 02)DAY(GETDATE()): "0"+(DT_WSTR, 02)DAY(GETDATE()))+""+RIGHT("0" + (DT_STR, 2, 1252)DATEPART("hh", GETDATE()), 2) +RIGHT("0" + (DT_STR, 2, 1252)DATEPART("mi", GETDATE()), 2) +RIGHT("0" + (DT_STR, 2, 1252)DATEPART("ss", GETDATE()), 2) + ".txt"

128797-screenshot-2021-09-03-092830.jpg

Then, set it as DestinationConnection with OverWrite=true as below.

128901-screenshot-2021-09-03-093040.jpg

Regards,

Zoe


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues October


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Do you have further question on this , could we offer more support?
If this helps on your issue, you could mark it as answer so other user with similar problem could see this easier. :)

0 Votes 0 ·