Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Renaming a Text file

Author  Topic 

vk18
Posting Yak Master

146 Posts

Posted - 2007-06-29 : 14:07:22
Hi,

I have this VB ActiveX Script that i am running in DTS. This functions moves the file from source location to E:\. This works fine. The Source file has the Same Name all the time. So when i move this file to E:\ i want to rename this file like E:\Programs1.txt. Second time when i move this file it should be like E:\Programs2.txt and so on.
Can any one help me with this. Appreciate your help
Thx


Function Main()

Dim sSourceFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
sSourceFile = "C:\Programs.txt"
Set oFile = oFSO.GetFile("C:\Programs.txt")

oFile.Move "E:\Programs.txt"

Main = DTSTaskExecResult_Success

End Function

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-29 : 14:14:41
I'm surprised you didn't just google this.

Renaming a file: http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/filesfolders/files/#RenameFile.htm

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2007-06-29 : 14:38:08
quote:
Originally posted by tkizer

I'm surprised you didn't just google this.

Renaming a file: http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/filesfolders/files/#RenameFile.htm

Tara Kizer
http://weblogs.sqlteam.com/tarad/



But everytime i move the file i want to rename with different file name. so that the old file will not be over written. Is it possible.?
Appreciate your help
Thx
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-29 : 14:47:08
Yes it's possible. You need to develop the new name and use that for the Move function.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2007-06-29 : 14:50:25
quote:
Originally posted by tkizer

Yes it's possible. You need to develop the new name and use that for the Move function.

Tara Kizer
http://weblogs.sqlteam.com/tarad/



Hi,

It is an automated process, the text files will be moving 10 everyday. so how can i put the name for example i want to put like
programs.txt and next time i move programs1.txt and next time programs2.txt and so on. Please advise
Thx
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-29 : 14:52:45
Check for which files exist already, then increment by 1.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2007-06-29 : 14:58:30
quote:
Originally posted by tkizer

Check for which files exist already, then increment by 1.

Tara Kizer
http://weblogs.sqlteam.com/tarad/



Hi,

I think i need to put in a loop, I tried but is giving me error.
here is the code. Can you help me
Thx
Function Main()

Dim sSourceFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
sSourceFile = "C:\Programs.txt"
Set oFile = oFSO.GetFile("C:\Programs.txt")

oFile.Move "E:\Programs.txt"

Main = DTSTaskExecResult_Success

End Function
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2007-06-29 : 18:04:55
quote:
Originally posted by tkizer

Check for which files exist already, then increment by 1.

Tara Kizer
http://weblogs.sqlteam.com/tarad/



Figured out
Thx
Go to Top of Page
   

- Advertisement -