Need to adjust Script to copy a specific file name.
There are many files in the folder.
I need to copy the ones that start with a name of "Batch*.html" and have been modified today.
I tried to add a \batch* to the CONST Path but it will not go.
Here is the code.
------------------------------------------------------------
Option Explicit
CONST PATH = "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data"
Dim strDate_2_Copy, strShare
Dim fso, objFolder, colFiles, objFile, strFile
Set fso = CreateObject("Scripting.FileSystemObject")
strDate_2_Copy = Date
strShare = "C:\EmailReport\"
If fso.FolderExists(PATH) Then
Set objFolder = fso.GetFolder(PATH)
Set colFiles = objFolder.Files
Else
Wscript.Echo "Can't find the " & PATH & " folder"
Wscript.Quit
End if
For Each strFile in colFiles
Set objFile = fso.GetFile(strFile)
If DateDiff("d", objFile.DateLastModified, strDate_2_Copy) = 0 Then
fso.CopyFile strFile, strShare & "\GPSBackup.log" , True
' Wscript.Echo strFile.Name & ", Mod-Date: " & objFile.DateLastModified & ", copied to " & strShare
End If
Set objFile = Nothing
Next
Wscript.Quit
------------------------------------------------------------
There are many files in the folder.
I need to copy the ones that start with a name of "Batch*.html" and have been modified today.
I tried to add a \batch* to the CONST Path but it will not go.
Here is the code.
------------------------------------------------------------
Option Explicit
CONST PATH = "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data"
Dim strDate_2_Copy, strShare
Dim fso, objFolder, colFiles, objFile, strFile
Set fso = CreateObject("Scripting.FileSystemObject")
strDate_2_Copy = Date
strShare = "C:\EmailReport\"
If fso.FolderExists(PATH) Then
Set objFolder = fso.GetFolder(PATH)
Set colFiles = objFolder.Files
Else
Wscript.Echo "Can't find the " & PATH & " folder"
Wscript.Quit
End if
For Each strFile in colFiles
Set objFile = fso.GetFile(strFile)
If DateDiff("d", objFile.DateLastModified, strDate_2_Copy) = 0 Then
fso.CopyFile strFile, strShare & "\GPSBackup.log" , True
' Wscript.Echo strFile.Name & ", Mod-Date: " & objFile.DateLastModified & ", copied to " & strShare
End If
Set objFile = Nothing
Next
Wscript.Quit
------------------------------------------------------------