cr4ckerK9 Posted November 13, 2008 Posted November 13, 2008 (edited) On XP.How To Find data in text file and replace it?I want Command Script in batch file or VBScripts---> .bat or .vbs------------------------------------------------------Example. Search Command "I Love You" in c:\Testt.txtand replace "I Love You" it is "HACK BY ME"and Search and replace "I Love You" in line 5 column 7save and exit.------------------------------------------------------Help me Plz. Edited November 13, 2008 by cr4ckerK9
IcemanND Posted November 14, 2008 Posted November 14, 2008 Const FOR_READING = 1Const FOR_WRITING = 2Const vbTextCompare = 1 ' essentatially case insensitveConst vbBinaryCompare = 0 ' case sensitvevbOldText = "I Love You"vbNewText = "HACK BY ME"strFileName = "C:\scripts\test.txt"strCheckForString = UCase("july")Set objFS = CreateObject("Scripting.FileSystemObject")Set objTS = objFS.OpenTextFile(strFileName, FOR_READING)strContents = objTS.ReadAllobjTS.CloseNewText = Replace(strContents, vbOldText, vbNewText, 1, -1, vbTextCompare)Set objTS = objFS.OpenTextFile(strFileName, FOR_WRITING)objTS.Write NewTextobjTS.Close
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now