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

Create a folder that includes date in the name 2

Status
Not open for further replies.

ljg

IS-IT--Management
Oct 2, 2002
163
US
Hoping someone can assist me. I'm looking for a way to create a folder using vbscript that includes the date in the name. I have the (very simple) script below, and it works as-is, but i want the destination folder to be g:\backups_date\ and I can't figure it out. Any help would be greatly appreciated -- I'm missing something. Can anyone tell me how to create the destination folder including the DATE?

*******************************
Option Explicit

dim destination
dim sourcefolder

destination = "g:\backups\"
sourcefolder = "c:\temp"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(destination)
objFSO.CopyFolder sourcefolder, destination

wscript.echo "Done copying files"

******************************

Thx,
LJG
 
A starting point:
destination = "g:\backups_" & (10000*Year(Date)+100*Month(Date)+Day(Date)) & "\"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV that was exactly what I was looking for. I had the general idea but could NOT get the syntax right. You made my day -- thanks!!
 
That's a cool way to do it PHV. You get a star from me as well.

Thanks!

h
 
Check THIS one out -- a coworker suggested this:

destination = "g:\_backups_" & Year(Date) & "-" & Month(Date) & "-" & Day(Date)

which gives me \_backups_2009-2-3\ (remove the dashes if you like)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top