chrisleeds
05-14-2002, 11:27 AM
I have writen the following script but I can not get the testfile.txt to move in to the BackUp dir. I am new to this so its probibly something simple I am missing.
'*** Little Script to check if a file exists ***
'*** Declare the variables ***
Dim fso, tf, MyDate, BackUp
'*** Use the file System Object
Set fso = CreateObject("Scripting.FileSystemObject")
'*** Get the Current Date **
CurrentDate = Date
MyDay = Day(CurrentDate)
MyMonth = Month(CurrentDate)
MyYear = Year(CurrentDate)
MyDate = MyDay & "-" & MyMonth & "-" & MyYear
'*** Create backup folder ***
Set BackUp = fso.CreateFolder("C:\" & MyDate)
'*** Check the file exists ***
If (fso.FileExists("c:\testfile.txt")) Then
'*** Create a file if it exists and write an success message to it ***
Set tf = fso.CreateTextFile("C:\" & MyDate & ".txt",True)
tf.WriteLine ("the file c:\testfile.txt exists and can be used at your lesure")
tf.close
'*** Copy TestFile.txt to the Backup Folder (The Bit that does not Work)
fso.CopyFile "c:\testfile.txt", "BackUpDir"
Else
'*** Create a error file if it does not exist and write a message to it
Set tf = fso.CreateTextFile("C:\" & MyDate & " " & MyTime & ".txt",True)
tf.WriteLine ("Help, file c:\testfile.txt does not exist, where is it?")
tf.close
End If
'*** Little Script to check if a file exists ***
'*** Declare the variables ***
Dim fso, tf, MyDate, BackUp
'*** Use the file System Object
Set fso = CreateObject("Scripting.FileSystemObject")
'*** Get the Current Date **
CurrentDate = Date
MyDay = Day(CurrentDate)
MyMonth = Month(CurrentDate)
MyYear = Year(CurrentDate)
MyDate = MyDay & "-" & MyMonth & "-" & MyYear
'*** Create backup folder ***
Set BackUp = fso.CreateFolder("C:\" & MyDate)
'*** Check the file exists ***
If (fso.FileExists("c:\testfile.txt")) Then
'*** Create a file if it exists and write an success message to it ***
Set tf = fso.CreateTextFile("C:\" & MyDate & ".txt",True)
tf.WriteLine ("the file c:\testfile.txt exists and can be used at your lesure")
tf.close
'*** Copy TestFile.txt to the Backup Folder (The Bit that does not Work)
fso.CopyFile "c:\testfile.txt", "BackUpDir"
Else
'*** Create a error file if it does not exist and write a message to it
Set tf = fso.CreateTextFile("C:\" & MyDate & " " & MyTime & ".txt",True)
tf.WriteLine ("Help, file c:\testfile.txt does not exist, where is it?")
tf.close
End If