I am new to Batch scripting and have searched all the material available but I did not get a satisfactory answer.
I have a string called find_str which has the following content
baseUrl:{development:"https://myserver.example:1234"}
I want to replace the url given in development with http://localhost:8084
So the output should look like
baseUrl:{development:"http://localhost:8084"}
I have a variable called
find_string which has https://myserver.example:1234 and a variable called
replacestr which has http://localhost:8084
I have referred to this site Replace a substring using string substitution
But there the string to be replaced is hardcoded , I want the string to be replaced to come from the variables given above and want to store the entire result in a third variable.
I have tried the following:
setlocal ENABLEDELAYEDEXPANSION
For /F "tokens=1* delims==" %%A IN (environment.properties) DO (
IF "%%A"=="url" set replacestr=%%B
)
set /p find_str=<%~dp0application\app\common\common.config.js
set cmd="echo %find_str:~92,37%"
FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET find_string=%%i
echo !find_string!
echo !replacestr!
break>%~dp0portfolio-analyzer\app\common\common.config.js
set _result=%find_str:=!replacestr!%
>> %~dp0portfolio-analyzer\app\common\common.config.js echo %_result%
pause
But it is not replacing the find_str with its value.
Thanks in advance.