Const adVarChar = 200
Const MaxCharacters = 255
strRoot = "C:\Customer Files"
strOutput = "C:\Index.htm"
strPattern = ".*\\([A-Z]\d{6,6})$"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutput = objFSO.CreateTextFile(strOutput, True)
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DieNumber", adVarChar, MaxCharacters
DataList.Fields.Append "Path", adVarChar, MaxCharacters
DataList.Open
strCommand = "cmd /c @echo off & dir " & _
Chr(34) & strRoot & Chr(34) & " /a:d /b /s"
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec(strCommand)
Set objStdOut = objWshScriptExec.StdOut
strList = objWshScriptExec.StdOut.ReadAll
Set objRegExp = New RegExp
objRegExp.Pattern = strPattern
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.MultiLine = True
Set objMatches = objRegExp.Execute(strList)
For Each objMatch in objMatches
DataList.AddNew
DataList("DieNumber") = objMatch.SubMatches(0)
DataList("Path") = objMatch.Value
DataList.Update
Next
DataList.Sort = "DieNumber"
DataList.MoveFirst
Do Until DataList.EOF
objOutput.WriteLine "" & _
DataList.Fields.Item("DieNumber") & " "
DataList.MoveNext
Loop
objOutput.Close
|