I have customer ids as the folder names. Each folder has a number of text files. Files with a modified date of 6/1/10 or less need to be moved to a zip file called "Jan-June.zip". The zip file will reside in a differnt folder, called "2010", which will reside under the customer's main folder. Neither the 2010 folder or the zip folder exist.
I found the following source code from and tried to modify it a little bit.
However, the code is picking up all the files regardless of the modified date.
I also need help with looping through the customer folders to execute this for all the folders.
Code so far:
*************************************************
Private Function MoveFiles()
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFill As String, strFolderPath As String
strFolderPath = "C:\Source\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Set objFiles = objFolder.files
For Each objF1 In objFiles
If objF1.DateCreated > 2 / 1 / 2010 Then
objFS.MoveFile strFolderPath & objF1.Name, "C:\Destination\"
End If
Next
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
End Function
**************************************************
Thank you
I found the following source code from and tried to modify it a little bit.
However, the code is picking up all the files regardless of the modified date.
I also need help with looping through the customer folders to execute this for all the folders.
Code so far:
*************************************************
Private Function MoveFiles()
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFill As String, strFolderPath As String
strFolderPath = "C:\Source\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Set objFiles = objFolder.files
For Each objF1 In objFiles
If objF1.DateCreated > 2 / 1 / 2010 Then
objFS.MoveFile strFolderPath & objF1.Name, "C:\Destination\"
End If
Next
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
End Function
**************************************************
Thank you