1.

Solve : Finding and replacing string in a file?

Answer»

I apologize for posting my Q in another's topic.

Thanks Sidewinder.....

Your code works PERFECT for my files....


Here is ur code: (Replacing \t (tab) with single SPACING)

Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2

Set fso = CreateObject("Scripting.FileSystemObject")
Set filein = fso.OpenTextFile("c:\a.txt", ForReading, TriStateUseDefault)
Set fileout = fso.OpenTextFile("c:\b.txt", ForWriting, TriStateUseDefault)
Do Until filein.AtEndOfStream
strLine = filein.ReadLine
strLine = Replace(strLine, vbTab, " ", 1, -1)
fileout.WriteLine strLine
Loop
filein.Close
fileout.Close

Set f = fso.GetFile("c:\a.txt")
f.Name = "DataFile.ini.old"
Set f = fso.GetFile("c:\b.txt")
f.Name = "DataFile.ini"



Save the script with a VBS extension and RUN from the command line as cscript scriptname.vbs




Once again thank you Sidewinder.

Wish u all have a wonderful new year.......
regards,
chinna



Discussion

No Comment Found