Re: Copying folder with all it's contents.



"Marc" <mevert@xxxxxxxxx> wrote in message
news:1160170251.080295.286990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
copy "c:\data\" all files and all folder to "d:\20061004\"
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
create
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


.



Relevant Pages

  • Object required: [string: "C:Documents and Set"] error message
    ... and Set"] when running the following script: ... Set objFSO = CreateObject ... Dim WSHShell ... directory called Network Applications. ...
    (microsoft.public.windows.server.scripting)
  • Re: Recurse issue - 2nd try
    ... My script simply stops short. ... However, when I view the log file, it is missing several files. ... > is your script hanging or does it complete but somehow misses some folders? ... >> Dim sLogFile ...
    (microsoft.public.scripting.vbscript)
  • Re: Setting Permissions to Home folders
    ... I have created this script and for some reason the script assigns only full ... permssions to user home folder i am not able to assign only Modify permission ... dim Fol ... Set objFSO = CreateObject ...
    (microsoft.public.windows.server.scripting)
  • How to consolidate two RegEx replacements into 1 script
    ... in the same script, i.e., the second replacement operation operating on the ... Dim objFso ... Dim objOutputFile ... Set objFSO = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Setting Permissions to Home folders
    ... first step must be to test this code from the Command Prompt. ... After you get it to work there, you can put it into your VB Script. ... dim Fol ... Set objFSO = CreateObject ...
    (microsoft.public.windows.server.scripting)