cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Renaming a file in VB Script

How do i rename a particaular file using vb script

c:\program files\msfs.dll to c:\program files\msfs.dll_
(3) Replies
Perhaps, you want to look up MoveFile method in FileSystemObject object.
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.GetFile(oldfileName)
file.Name = newfileName
Hi,
As TsungH had instructed, you can use the MoveFile method which will rename the file.

********VB Script to rename the file ***********

Set fso=CreateObject("Scripting.FileSystemObject")

oldFile = "C:\Program Files\msfs.dll"

Set f = fso.GetFile(oldFile)

f.Move "C:\Program Files\msfs.dll_"

set f = Nothing
Set fso = Nothing

***************** End of VB Script ***************

let me know if this helped in some way....