VBScript Subroutine to Create/Rename Windows Folder(s)

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

VBScript Subroutine to Create/Rename Windows Folder(s)

Post by armsys » Tue Dec 28, 2004 12:42 am

Task Goal: Write a Macro Scheduler script to back up multiple versions of files into multiple folders, say c:\2004.12.25, c:\2004.12.26, c:\2004.12.27,....etc.

Would someone be very kind enough to show me how to CREATE and RENAME a folder with VBScript? Thanks a lot in advance.

Happy scripting. Happy New Year.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Dec 28, 2004 8:51 am

MJT Net Support
[email protected]

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Dec 28, 2004 9:03 am

Hi Support,

Thanks a lot. Actually, the URL you pointed to contains all the sample scripts I need. Thanks to your help, I wrote the following script:

/* 12/28/2004 Tue 5:30:35 PM HKT*/
VBSTART
Function CreateFolder(Folder)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")

If (fso.FolderExists(Folder)) Then
Else
Set f = fso.CreateFolder(Folder)
CreateFolder = f.Path
End If
End Function
VBEND

Let>Date=c:\Backup\2004.12.25
VBrun>Createfolder,%date%

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts