I have a basic question about a simple VBScript. My goal is to find a replace multiple text strings in multiple files. (The 21 text strings to replace are the same across files.) The file names have about 12 prefixes and then will have numbers 1 to 200 at the end. The code I am using for just one of the strings in one of the files is as follows.
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\filename_XX.txt", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "Test 1", "Test 2")
Set objFile = objFSO.OpenTextFile("C:\filename_XX.txt", ForWriting)
objFile.Write strNewText
objFile.Close
I just want to loop over the file names and possibly loop over the search strings. Could a For...Next loop accomplish this? Can I refer to the number of the for loop in the filename object?
I have seen a response about searching over subfolders, but I think it is more sophisticated than what I need to do.