Please I need help with below 2 scripting challenges I am facing. I am using
I want to be able to replace a text in a text file in a specific location
Let say I have a text file that contains the following "I bought a car and I bought a shoe and I bought a Laptop"
I need I script that can read this text file and only change "I bought a shoe" to I sold a Shoe"
The end result of my text file will be "I bought a car and I sold a shoe and I bought a Laptop"
Please Note that the text file has more than one line of text . I want to be able to change any text of interest based on the location of the text in the file while not changing other occurrences of the same text in other locations of the file.
Below script I used does a replace all and that is not what I want. So How can I modify below script to give me what I want
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Text.txt", ForReading)
strText = objFile.ReadAll
strNewText = Replace(strText, "Jim ", "James ")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Text.txt", ForWriting)
Set objFSO = Nothing