Jump to content

Urgent ind replace fline/append ine next to the line in html using batch file


Recommended Posts

Posted

Const ForReading = 1

Const ForWriting = 2

 

set objShell = CreateObject("WScript.Shell")

Set objFSO = CreateObject("Scripting.FileSystemObject")

 

Dim StringFind, StringReplace

 

StringFind = "put your string in here to find"

StringReplace = "put your replacement string in here"

 

FileName = objFSO.GetFile("pathname and file name to file to look in")

 

Set objFile = objFSO.OpenTextFile(FileName, ForReading)

strContents = objFile.ReadAll

objFile.Close

 

If InStr(strContents,StringFind) then

 

strContents = Replace(strContents, StringFind, StringReplace)

 

Set objFile = objFSO.OpenTextFile(FileName, ForWriting)

objFile.WriteLine strContents

objFile.Close

 

Else

 

'Do nothing

 

End If

Posted

So...you want a batch to do the following...

 

open a file

find a line in the file

replace the line in the file

save the file

close the file

 

rinse and repeat..think you would be better off with a VBScript tbh, as a batch is more for mapping things and services etc.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...