Hi all,
I have pilfered through a lot of posts but can't seem to combine exactly what I'm trying to do. I have a bit of code here but basically, instead of the .txt files I want it to cycle through every file in each folder and match them against each other. If the file doesn't exist in the folder I want to overwrite to it would simply just copy it over, if the date of the file is newer in the LocalFile folder than it is in the ServerFile folder than it will overwrite it into the ServerFile folder.
I know there are tweaks needed to this, probably pointing to the specific folders and some looping but I'm not exactly sure of the syntax, if anybody has any direction it is greatly appreciated! Thanks
I have pilfered through a lot of posts but can't seem to combine exactly what I'm trying to do. I have a bit of code here but basically, instead of the .txt files I want it to cycle through every file in each folder and match them against each other. If the file doesn't exist in the folder I want to overwrite to it would simply just copy it over, if the date of the file is newer in the LocalFile folder than it is in the ServerFile folder than it will overwrite it into the ServerFile folder.
I know there are tweaks needed to this, probably pointing to the specific folders and some looping but I'm not exactly sure of the syntax, if anybody has any direction it is greatly appreciated! Thanks
Code:
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLocalFile = objFSO.GetFile("c:\scripts\test.txt")
dtmLocalDate = objLocalFile.DateLastModified
Set objServerFile = objFSO.GetFile("\\source\public\test.txt")
dtmServerDate = objServerFile.DateLastModified
If dtmLocalDate < dtmServerDate Then
objFSO.CopyFile objServerFile.Path, objLocalFile.Path, OverwriteExisting
End If