script to find string in text file, replace

Microsoft Windows xp professional w/sp2
March 23, 2010 at 05:28:09
Specs: Windows XP
Hi I am a beginner in VBScripting. The task i have now is to find a string in a file and replace it with one more string. The code i checked for this was,

Dim FileName As String = "C:\bin_sdk\web.xml"
Dim Find As String = "serverName"
Dim ReplaceWith As String = "linbgy143"
Dim FileContents As String
Dim dFileContents As String

'Read source text file
FileContents = GetFile(FileName)

'replace all string In the source file
dFileContents = replace(FileContents, Find, ReplaceWith, 1, -1, 1)

'Compare source And result
If dFileContents <> FileContents Then
'write result If different
WriteFile FileName, dFileContents
End If

But i am getting an error, " Expected end of statement at line 1 character 14 ",

Can anybody help me getting through with this..??


See More: script to find string in text file, replace

Report •

March 24, 2010 at 08:52:12
Do you realize that VBScripting has absolutely nothing to do with DOS?

Try the programming forum.

Report •
Related Solutions

Ask Question