I am trying to write a script that will look at a source directory, make a list of all the files and folders below it and then compaire this with another directory and copy any missing files and create any missing folders.
So far all I can do is look at the source directory and see a folder below it, I cannot find a way to go further into sub folders. This is what I have so far:
Set objFSO = createobject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile (strLogFile, ForAppending)
objLogFile.WriteLine "Customer configs Backup ran at " &Now
CompareDirs strSourceFolder, strDestinationFolder
Set objFSO = nothing
sub CompareDirs(byval strSourceDir,byval strDestinationDir)
Dim objFolder
Dim objSubFolder
Dim objFiles
Dim objSubFolders
Dim objFile
Set objFolder = objFSO.GetFolder(strSourceDir)
Set objFiles = objFolder.Files
For Each objFile in objFiles
objLogFile.WriteLine("File," &objFile.Name & "," & objFile.Path)
Next
Set objSubFolders = objFolder.SubFolders
For Each objFolder in objFolder.SubFolders
objLogFile.WriteLine("Folder," &objFolder.Name & "," &objFolder.Path)
Next
end sub
Can anyone help with a solution ?
So far all I can do is look at the source directory and see a folder below it, I cannot find a way to go further into sub folders. This is what I have so far:
Set objFSO = createobject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile (strLogFile, ForAppending)
objLogFile.WriteLine "Customer configs Backup ran at " &Now
CompareDirs strSourceFolder, strDestinationFolder
Set objFSO = nothing
sub CompareDirs(byval strSourceDir,byval strDestinationDir)
Dim objFolder
Dim objSubFolder
Dim objFiles
Dim objSubFolders
Dim objFile
Set objFolder = objFSO.GetFolder(strSourceDir)
Set objFiles = objFolder.Files
For Each objFile in objFiles
objLogFile.WriteLine("File," &objFile.Name & "," & objFile.Path)
Next
Set objSubFolders = objFolder.SubFolders
For Each objFolder in objFolder.SubFolders
objLogFile.WriteLine("Folder," &objFolder.Name & "," &objFolder.Path)
Next
end sub
Can anyone help with a solution ?