I have a json file(config.json) with the contents as shown below.
{
"context" : {
"inprocAddress" : "inproc://bigpc",
"uniqueIdentity" : 3,
"name" : "ccontroller"
},
"controllerListenerPort" : 3051,
"controllerServerHandshakePort" : 3052,
"controllerServerInprocAddress" : "inproc://controllerdeal",
"controllerServerRouterPort" : 3054,
"controllerServerNumWorkers" : 44,
"controllerNumContextThreads" : 1,
"mongoConnectionPoolSize" : 44,
"fileSystemRootDirectory" : "C:/Controller/ControllerData",
"mongoURI" : "mongodb:desktop-stl.mo.mywebsite.com:27017/"
}
I want to replace the value of mongoURI
tag to mongodb:localhost:27017/
.
I tried using the following script, but I'm unable to setup the regex part.
setlocal enableextensions disabledelayedexpansion
set "search="mongodb"
set "replace="mongodb://localhost:12707""
set "textFile=C:\Users\shravan\Documents\Rahul\config.json"
for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
>>"%textFile%" echo(!line:%search%=%replace%!
endlocal
)
With this script, I get the following as the replaced text at mongoURI:
"mongoURI" : "mongodb://localhost:12707":desktop-cblrrri.stl.mo.boeing.com:27017/"