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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to rename a file in vbscript?

Status
Not open for further replies.

bnath005

MIS
Aug 19, 2005
14
US
I saw only Copy, Delete methods (file scripting object).

thanks
nath

 
what about the Move method ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Two ways:
The Name property is writable ...
The "Rename" method is called Move ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
phv's suggestion is preferred since it's done in vbs.
however, you can use dos commands in vbs to do it:
Code:
wshshell.Run("cmd.exe /c ren oldfile newfile")
 
as per phv, the name property is writable. here's the code to do that with:
Code:
stPath = "C:\oldfile.txt"    
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(stPath)
objFile.name = "newfile.txt"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top