Q:

VBScript to find and move files automatically

I've been tasked with trying to automate a task at work, because we've had issues lately with people remembering to do it. 
In general, here's what I need a script to do:

Get the date of the previous day, in the format YYYYMMDD
Enter a folder with that given name
Search within all the folders underneath that location for 4 specific files
Copy those files to several different locations

The issue I'm having is that, for the 4 files I'm looking for, they're located in 2 different folders.  3 in 1, 1 in the other.  The names of these folders changes daily, depending on what queue they got put into when generated by some other software.  I need these files to be moved so that another script can be run on them.  I'm having trouble figuring out how to accomplish this.  Anyone have some ideas? 

A:

If the folders containing the interesting files are subfolders of your dated directory, you can use a nested loop:
  Dim sDFolder : sDFolder    = "..\data\20110105"
  Dim dicFiNa  : Set dicFiNa = CreateObject("Scripting. Dictionary")
  dicFiNa("1.txt") = ""
  dicFiNa("3.txt") = ""
  dicFiNa("5.txt") = ""
  Dim oRDir     : Set oRDir  = goFS.GetFolder(sDFolder)
  Dim oSDir
  For Each oSDir In oRDir. SubFolders
      Dim oFile
      For Each oFile In oSDir. Files
          WScript. Echo "looking at", oFile. Path
          If dicFiNa. Exists(oFile. Name) Then
             WScript. Echo "found", oFile. Name, "will copy"
          End If
      Next
  Next

output:
looking at E:\trials\SoTrials\answers\8750206\data\20110105\whatever\6.txt
looking at E:\trials\SoTrials\answers\8750206\data\20110105\whatever\5.txt
found 5.txt will copy
looking at E:\trials\SoTrials\answers\8750206\data\20110105\unknown\4.txt
looking at E:\trials\SoTrials\answers\8750206\data\20110105\unknown\3.txt
found 3.txt will copy
looking at E:\trials\SoTrials\answers\8750206\data\20110105\puzzle\2.txt
looking at E:\trials\SoTrials\answers\8750206\data\20110105\puzzle\1.txt
found 1.txt will copy

A full recursive walk would be a bit more complex, so say so, if you need it. 

Just for fun: a recursive version:
  Dim sDFolder : sDFolder    = "..\data\20110105"
  Dim dicFiNa  : Set dicFiNa = CreateObject("Scripting. Dictionary")
  dicFiNa("1.txt")  = ""
  dicFiNa("3.txt")  = ""
  dicFiNa("55.txt") = ""
  Dim oRDir     : Set oRDir  = goFS.GetFolder(sDFolder)
  walk oRDir, dicFiNa, "whatever you need to copy the files"

Sub walk(oDir, dicFiNa, vCargo)
  Dim oItem
  For Each oItem In oDir. Files
      WScript. Echo "looking at", oItem. Path
      If dicFiNa. Exists(oItem. Name) Then
         WScript. Echo "found", oItem. Name, "will copy"
      End If
  Next
  For Each oItem In oDir. SubFolders
      walk oItem, dicFiNa, vCargo
  Next
End Sub

output:
looking at E:\trials\SoTrials\answers\8750206\data\20110105\whatever\6.txt
looking at E:\trials\SoTrials\answers\8750206\data\20110105\whatever\5.txt
looking at E:\trials\SoTrials\answers\8750206\data\20110105\unknown\4.txt
looking at E:\trials\SoTrials\answers\8750206\data\20110105\unknown\3.txt
found 3.txt will copy *
looking at E:\trials\SoTrials\answers\8750206\data\20110105\puzzle\2.txt
looking at E:\trials\SoTrials\answers\8750206\data\20110105\puzzle\1.txt
found 1.txt will copy *
looking at E:\trials\SoTrials\answers\8750206\data\20110105\puzzle\deep\deeper\55.txt
found 55.txt will copy *

(*) as soon as the permission problem is solved.