Copy folders from a text file RRS feed

  • Question

  • I have a script that searches a drive for a specific folder name and writes to a text file with the path. I would like to create a sub routine to then read the text and make a copy of that folder and contents to a USB Hard drive. (If possible with a progress bar to show me the status of the copy operation . ) Here is a copy of the code that I'm using.

    Thank you all in advance. -Jeremy


    Set objRegEx = CreateObject("VBScript.RegExp")
    Set objFSO=CreateObject("Scripting.FileSystemObject")
    Set objFile=objFSO.CreateTextFile("C:\SearchLog.txt") 'Added to log the results

    objRegEx.Global = True
    objRegEx.IgnoreCase = True
    objRegex.Pattern = "^.*\b(Starwood Hotels)\b.*$"
    'objRegEx.Pattern = "^bad_\d{8}"

    strComputer = "."

     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
     Set colFolders = objWMIService.ExecQuery("Select * From Win32_Directory")
     For Each objFolder in colFolders  
      strFolder = objFolder.FileName
          Set colMatches = objRegEx.Execute(strFolder)  
           If colMatches.Count > 0 Then   
               objFile.WriteLine objFolder.Name
               'Wscript.Echo objFolder.Name   'Replace with above to write to text
                End If

    • Moved by Jeff Shan Monday, January 25, 2010 6:08 AM vb script question (From:Visual Basic General)
    Thursday, January 21, 2010 4:15 PM

All replies