I am writing a batch script to update a properties file. I am able to update the properties file and redirect the output to another file. But i want to update the same properties file and maintain all the comments and blank line as it is.
example: project properties
Set "portNum=8080"
Set "hostname=localhost"
Set "FindportNum=^<port_number^>"
Set "Findhost=^<host^>"
Set "username=someusername"
Set "password=somepassword"
Set "applicationAdminstratorUsername=someapplicationAdminstratorUsername"
Set "applicationAdminstratorPassword=someapplicationAdminstratorPassword"
Set "textFile=C:\Users\Varun\...\installer\none.properties"
Set "textFileOut=C:\Users\...\installer\NewData.txt"
@Echo off&SetLocal
( for /f "usebackq tokens=1* delims==" %%i in (
"%textFile%"
) do If "%%i" equ "Username" (
echo Username=%username%
) else If "%%i" equ "Password" (
echo Password=%password%
) else If "%%i" equ "consumer_key" (
echo consumer_key=%consumerKey%
) else If "%%i" equ "consumer_secret" (
echo consumer_secret=%consumerSecret%
) else If "%%i" equ "c360rest.username" (
echo c360rest.username=%applicationAdminstratorUsername%
) else If "%%i" equ "c360rest.password" (
echo c360rest.password=%applicationAdminstratorPassword%
) else if "%%j" neq "" (
echo %%i=%%j
) else (
echo %%i
)
) >C:\Users\...\installer\NewData.txt
pause
Please tell me how to update a properties file directly without redirecting its processed output to another file.
Thank you