Re: Copying folder with all it's contents.
- From: "McKirahan" <News@xxxxxxxxxxxxx>
- Date: Fri, 6 Oct 2006 22:20:02 -0500
"Marc" <mevert@xxxxxxxxx> wrote in message
news:1160170251.080295.286990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
copy "c:\data\" all files and all folder to "d:\20061004\"create
the script will be ran once a day with xp task manager
.
then have a logfile (text file) that the script apends to when ran and
saved to d:\
just saying:
**********************
Started:10/05/06 15:00
Task: files copied from <c:\data\> to <d:\20061004\>
Completed: Started:10/05/06 15:30
***********************
Started:10/05/06 15:00
Task: files copied from <c:\data\> to <d:\20061004\>
Completed: Started:10/05/06 15:30
***********************
Thanks Alot!! for your intrest in helping.
Marc
McKirahan wrote:
"McKirahan" <News@xxxxxxxxxxxxx> wrote in message
news:o_-dnbzd54rtS77YnZ2dnUVZ_oydnZ2d@xxxxxxxxxxxxxx
"Marc" <mevert@xxxxxxxxx> wrote in message
news:1159908596.017065.151230@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello Everyone,
I'm unable to find what I'm looking for..need some help.
Issue: vbs script to copy all files and folders from c:\data and
a new folder d:\<todays date> and copy all files and subfolders from
d:\data to d:\<todays date> then create a log file in same folder
saying completed date and time.
What happened to the requirement to backup d:\data ? Anyway:
Will this help? Watch for word-wrap.
'****
'* Backup files and folders:
'* 1) Create D:\yyyymmdd
'* 2) Copy C:\data (files and folders) into D:\yyyymmdd\
'* 3) Write log file
'****
Option Explicit
'*
'* Declare Constants
'*
Const cVBS = "copydata.vbs"
Const cLOG = "copydata.log"
Const cCF1 = "C:\data"
'*
'* Declare Variables
'*
Dim strCTF
strCTF = "Started: " & Now & vbCrLf
Dim dtmDAT
dtmDAT = Date
Dim strDAT
strDAT = CStr((Year(dtmDAT)*10000)+(Month(dtmDAT)*100)+Day(dtmDAT))
Dim strMSG
Dim strOUT
strOUT = "D:\" & strDAT & "\"
strCTF = strCTF & "Task: files copied from " & cCF! & " to " &
strOUT & vbCrLf
Dim strSUB
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objCTF
'*
'* Test Folder
'*
If objFSO.FolderExists(strOUT) Then
strMSG = strOUT & " exists!"
Else
'*
'* Create Folder
'*
objFSO.CreateFolder(strOUT)
strMSG = strOUT & " created;" & vbCrLf
'*
'* Copy Folders
'*
objFSO.CopyFolder cCF1, strOUT
strMSG = strMSG & cCF1 & " copied;" & vbCrLf
'*
'* Write Log
'*
Set objCTF = objFSO.CreateTextFile(strOUT & cLOG)
objCTF.WriteLine strCTF & "Completed: " & Now
Set objCTF = Nothing
strMSG = strMSG & cLOG & " log created."
End If
'*
'* Destroy Objects
'*
Set objFSO = Nothing
'*
'* Finish Message
'*
MsgBox strMSG,vbInformation,cVBS
.
- Follow-Ups:
- Re: Copying folder with all it's contents.
- From: Marc
- Re: Copying folder with all it's contents.
- References:
- Copying folder with all it's contents.
- From: Marc
- Re: Copying folder with all it's contents.
- From: McKirahan
- Re: Copying folder with all it's contents.
- From: McKirahan
- Re: Copying folder with all it's contents.
- From: Marc
- Copying folder with all it's contents.
- Prev by Date: Re: date manipulation
- Next by Date: Re: An ASP question or is it VBScript ??
- Previous by thread: Re: Copying folder with all it's contents.
- Next by thread: Re: Copying folder with all it's contents.
- Index(es):
Relevant Pages
|
|