Sub LookForDirs(fldrs, root)
Dim fldr
For Each fldr In fldrs
If fldr.Files.Count > 0 Then
LookForFiles fldr.Files, root
End If
If fldr.SubFolders.Count > 0 Then
LookForDirs fldr.SubFolders, root
End If
Next
End Sub
Sub LookForFiles(files, path)
Dim objC, f
Set objC = CreateObject("Scripting.FileSystemObject")
For Each f In Files
If objC.FileExists(path&"\"&f.Name) = False Then
f.copy path&"\"&f.Name, False
Wscript.Echo "Copied: " & f.Name
Else
Wscript.Echo "File exists in root: " & f.Name
End If
Next
End Sub
Dim path, objA, objB
path = Wscript.Arguments.Item(0)
Set objA = CreateObject("Scripting.FileSystemObject")
If objA.FolderExists(path) = False Then
Wscript.Echo "That is not a folder path"
Wscript.Quit
End If
Set objB = objA.GetFolder(path)
LookForDirs objB.SubFolders, path
Comments