LearnItFirst User Forum

SQL Server 2008 SSAS Training Videos
Welcome Guest Search | New Posts | Members | Log In | Register

How do you copy a file to another folder using the current datetime as part of the file name? Options
WayneL15
Posted: Monday, May 11, 2009 11:50:19 AM
Rank: Newbie

Joined: 3/25/2009
Posts: 5
Points: 15
Where do you live?: New York
I have an SSIS package that:

1. Via execute task, exports data to a flat file using BCP to the local file system. D:\output\myfile.txt
2. Sends the file to another server via FTP.

Now I need to copy the file as an archive file to a different folder on the same local server.
I would like the file to be renamed from D:\output\myfile.txt to D:\output\Success\myfile_YYYYMMDD_HHMM.txt

arkblue">I think the following could be used to generate an archive file name, but I am not sure where and in which object this should be placed to work properly.

@[User::ArchivePathSuccess] + @[User::SuccessCopyFileNamePrefix] + REPLACE(REPLACE( SUBSTRING( (DT_WSTR, 30) GETDATE(), 1, 17 ) , " ", "_"Wink,":",""Wink +".txt"

The variables have been set as follows: ArchivePathSuccess = D:\output\success\ SuccessCopyFileNamePrefix = myfile

Any suggestions?

Thank you for yor help in advance.
WayneL15
Posted: Monday, May 11, 2009 2:11:01 PM
Rank: Newbie

Joined: 3/25/2009
Posts: 5
Points: 15
Where do you live?: New York
Found this link: http://rafael-salas.blogspot.com/2007/03/ssis-file-system-task-move-and-rename.html

Also how might you delete files older than a certain date from a folder.

Thank you.
Scott Whigham
Posted: Tuesday, May 12, 2009 11:58:39 AM


Rank: Super Mod

Joined: 3/20/2006
Posts: 476
Points: 1,053
Where do you live?: Dallas, TX
Very nice - thanks!
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.