I want to be able read in two variables at a time into a VBScript. What I'm doing is replacing certain text from a bunch of HTML files. I have a script already written to do this, but I have to input only one set of text at a time. Command line Example:
C:> replace.vbs (OldText) (NewText)
where (OldText) and (NewText) are both parameters.
strOldText = WScript.Arguments.Item(0)
strNewText = WScript.Arguments.Item(1)
Is there a way to have a text file set up like:
(OldText) (NewText)
(OldText) (NewText)
(OldText) (NewText)
(OldText) (NewText)
and have the script read one at a time?
My find and replace code works perfectly. I would just like to automate the script to read the parameters from the text file rather than me typing them in one at a time in command prompt.
Any help is greatly appreciated. If further information is needed please let me know. I hope it's clear. Thanks
I would probably use PowerShell for the whole thing instead of just to call the script, but I think this should work. If not, the problem is probably in how I'm trying to call the vbscript in my example.
PowerShell:
Import-CSV textReplace.csv | % {
wscript.exe replace.vbs $_.OldText $_.NewText
}
CSV content:
OldText,NewText
"String 1","String 2"
"String 3,"String 4"