Below is a VBScript I’m using to copy a file and it works great but I need to add one feature, which I don’t know how to do. Can someone please help me? What I need it to do is this. After the file is copied add a line in a text file (logs.txt) stating completed with the date time and file name. If the file does exist or does not get copied put a note in the (Logs.txt) stating did not complete /copy files does exist add data and time. Have each entry added to the log.txt file on a new line.
Set Fso = CreateObject("Scripting.FileSystemObject")
Dim fso, fso2, dp, nx, i, File, Files, f
Set fso = CreateObject("Scripting.FileSystemObject")
fullfldr = "DC-FULL_GAO_TREE-" & MonthName(Month(now()), true) & "-" & DatePart("d", Date()) & "-" & DatePart("yyyy", Date())
'change folder structure
Set FldrObj = FSO.GetFolder("D:\Ecora\Auditor36\Novell\data\")
For Each objSubFolder In FldrObj.SubFolders
'change folder structure and change 58 to include additional folder lengths
if lcase(left(objSubFolder.Path,58)) = lcase("D:\Ecora\Auditor36\Novell\data\" & fullfldr) then
'msgbox lcase(left(objSubFolder.Path,58))
'Set FldrObj2 = FSO.GetFolder(objSubFolder.Path)
Dim a
Set a = fso.GetFile( objSubFolder.Path & "\csv")
a.Copy "d:\csv"
end if
next
Set Fso = CreateObject("Scripting.FileSystemObject")
Dim fso, fso2, dp, nx, i, File, Files, f
Set fso = CreateObject("Scripting.FileSystemObject")
fullfldr = "DC-FULL_GAO_TREE-" & MonthName(Month(now()), true) & "-" & DatePart("d", Date()) & "-" & DatePart("yyyy", Date())
'change folder structure
Set FldrObj = FSO.GetFolder("D:\Ecora\Auditor36\Novell\data\")
For Each objSubFolder In FldrObj.SubFolders
'change folder structure and change 58 to include additional folder lengths
if lcase(left(objSubFolder.Path,58)) = lcase("D:\Ecora\Auditor36\Novell\data\" & fullfldr) then
'msgbox lcase(left(objSubFolder.Path,58))
'Set FldrObj2 = FSO.GetFolder(objSubFolder.Path)
Dim a
Set a = fso.GetFile( objSubFolder.Path & "\csv")
a.Copy "d:\csv"
end if
next