Task

Replace every occurring instance of a piece of text in a group of text files with another one.



For this task we want to replace the text   "Goodbye London!"   with   "Hello New York!"   for a list of files.




 
Const ForReading = 1
Const ForWriting = 2
 
strFiles = Array("test1.txt", "test2.txt", "test3.txt")
 
With CreateObject("Scripting.FileSystemObject")
	For i = 0 To UBound(strFiles)
		strText = .OpenTextFile(strFiles(i), ForReading).ReadAll()
		With .OpenTextFile(strFiles(i), ForWriting)
			.Write Replace(strText, "Goodbye London!", "Hello New York!")
			.Close
		End With
	Next
End With
 