Open a file with a wild card in VBS
Posted on 2010-09-08
Below is my VBScript to open and do something to a file.
Since VBS does not easily support wild cards, how would I be able to code around that problem in this instance. The file name that I need to open is POD2_h837.20100902.04365 and it changes daily.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("*h837*", 1)
strSearchString = objFile.ReadAll
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "BHT"
strNewText = objRegEx.Replace(strSearchString,VBCrlf & "BHT" & VBCrLf)
Set objOutFile = objFSO.CreateTextFile("837a.txt", 2)