• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

best way to rename files in SSIS

Greetings . . . I'm helping to convert a number of DTS packages to DTSX.   There are a number of ActiveX scripts which no longer function, and I need to find alternative means of doing those tasks.  The most common one is to rename a flat file using today's date, for instance renaming:




I've attached the old script below.  It's very simple, but SSIS doesn't like it.  How would I do this in a way that SSIS likes?
'  Visual Basic ActiveX Script
Function Main()
	dim fso
	dim d
	dim m
	dim y
	d = day(date)
	m = month(date)
	y =  year(date)
	if len(d) = 1 then d = "0" & d
	if len(m) = 1 then m = "0" & m
	set fso = createobject("Scripting.FileSystemObject")
	fso.copyfile "C:\test\Refresh_yyyymmdd.txt", "C:\test\GW_Refresh_" & m & d & y & ".txt"
	fso.DeleteFile "C:\test\Refresh_yyyymmdd.txt"	
	Main = DTSTaskExecResult_Success
End Function

Open in new window

  • 2
  • 2
1 Solution
You'll have to write it in VB.NET Syntaxt.  The first thing I notice is that you dim variables but not as a type.  

So you have to declare the type of your variables as a starter.
Second, I would say if you're using SSIS and you want to transfer files:  Use the FILE SYSTEM TASK task.  It will do all this for you.  use a variable for the destination name including todays date.  and voila.
rsmucklesAuthor Commented:
I understand that ultimately any complex scripts in ActiveX will need to be written again in .NET.  Is there, however, another way for me to do a text replace in a filename with today's date?  I am mostly a hardware & database guy and am just helping with this initiative, so learning how to be a programmer for this one task is not a realistic option.  
rsmucklesAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now