Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB script

Status
Not open for further replies.
Joined
Dec 17, 2003
Messages
39
Location
US
I don't know much about VB script but I need a script to rename a text file to another location. Can you help me please?
 
Do you want to move or copy the file?

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
I have a 6059.scr file in a folder that simply needs to be named 6059.txt within the same directory structure.
 
Code:
Option Explicit
Dim oFSO

Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists("6059.scr") = True Then
  oFSO.CopyFile("6059.scr", "6059.txt")
Else
  'The first file was not there
  WScript.Quit()
End If

If oFSO.FileExists("6059.txt") = True Then
  oFSO.DeleteFile("6059.scr")
Else
  'There was a problem with the copy because the
  'new file is not present
End If

Set oFSO = Nothing

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top