I need some code that will copy all .txt files in directory C:\Bat to C:\Bat\Bat2. I only want to copy the files that were modified b/w 06:00 PM the day before and now. So far, this is what I have for code:
Public Function GetYesterdyFiles()
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFill As String, strFolderPath As String
strFolderPath = "C:\Bat\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Set objFiles = objFolder.files
For Each objF1 In objFiles
If Right(objF1.Name, 3) = "txt" And objF1.DateLastModified = DateAdd("d", -1, Date) Then
objFS.CopyFile strFolderPath & objF1.Name, "C:\Bat\Bat2\"
End If
Next
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
End Function
Any help would be great............. Thanks!
Public Function GetYesterdyFiles()
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFill As String, strFolderPath As String
strFolderPath = "C:\Bat\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Set objFiles = objFolder.files
For Each objF1 In objFiles
If Right(objF1.Name, 3) = "txt" And objF1.DateLastModified = DateAdd("d", -1, Date) Then
objFS.CopyFile strFolderPath & objF1.Name, "C:\Bat\Bat2\"
End If
Next
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
End Function
Any help would be great............. Thanks!