Advertisement
andrewb

copy-up.vbs

Feb 17th, 2015
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub LookForDirs(fldrs, root)
  2.     Dim fldr
  3.    
  4.     For Each fldr In fldrs
  5.         If fldr.Files.Count > 0 Then
  6.             LookForFiles fldr.Files, root
  7.         End If
  8.        
  9.         If fldr.SubFolders.Count > 0 Then
  10.             LookForDirs fldr.SubFolders, root
  11.         End If
  12.     Next
  13. End Sub
  14.  
  15. Sub LookForFiles(files, path)
  16.     Dim objC, f
  17.     Set objC = CreateObject("Scripting.FileSystemObject")
  18.     For Each f In Files
  19.         If objC.FileExists(path&"\"&f.Name) = False Then
  20.             f.copy path&"\"&f.Name, False
  21.             Wscript.Echo "Copied: " & f.Name
  22.         Else
  23.             Wscript.Echo "File exists in root: " & f.Name
  24.         End If
  25.     Next
  26. End Sub
  27.  
  28. Dim path, objA, objB
  29.  
  30. path = Wscript.Arguments.Item(0)
  31.  
  32. Set objA = CreateObject("Scripting.FileSystemObject")
  33.  
  34. If objA.FolderExists(path) = False Then
  35.     Wscript.Echo "That is not a folder path"
  36.     Wscript.Quit
  37. End If
  38.  
  39. Set objB = objA.GetFolder(path)
  40.  
  41. LookForDirs objB.SubFolders, path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement