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

Rename Command

Status
Not open for further replies.

volleyman

MIS
Jun 12, 2002
183
US
I am attempting to use the rename command with a variable and I'm having no success.

Here is the scenario: I am moving a file named file1.txt into a directory. I then want to rename it using something unique like date and time so that I can later move a different file into the directory that also is named file1.txt

any ideas?

thanks in advance!




Zane D.
Systems Admin
 
vbscript

Code:
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")

FileName = Inputbox ("file Name")
	
strFileName = FileName
sfol = "c:\backup\" & strFileName
dfol = "C:\backup\"

strDate = "-" & Year(Now) & "-" & Right("0" & Month(Now),2) & "-" & Right("0" & Day(Now),2) 

objFSO.MoveFile sFol & ".txt" , dFol & "\" & strfileName  & strDate & ".txt"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top