Solved Need to update the property file using Batch script

January 30, 2020 at 00:55:08
Specs: Windows 10
Hi All,

i have one property file where i need to update the more than one value in property file using batch . i have using the script
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
call %~dp0\Batchenv.bat

SET sourcedir=C:\Users\1026478\Desktop\local
(
FOR /f "usebackqdelims=" %%a IN ("%sourcedir%\test.Property") DO (
FOR /f "tokens=1*delims==" %%g IN ("%%a") DO (
IF /i "%%g"=="INSTALL_PROD" (ECHO(%%g=%INSTALL_PROD%
) ELSE (ECHO(%%a)
)
)
)>newfile.property
:: newfile.txt now contains a modified version.
:: This line will overwrite the original

MOVE /y newfile.Property "%sourcedir%\test.Property"

GOTO :EOF
but this script only update one value in property file.. i need to update more than one value .

my property file like


I2_JDK_HOME=D:\\Java8\\jdk1.8.0_181
I2_LICENSE_FILE=D:\\license\\PSA100417.lic
I2_LICENSE_FILE_LOCATION=D:\\license
I2_LICENSE_FILE_NAME=PSA100417.lic
I2_ORACLE_DRIVER=oracle.jdbc.driver.OracleDriver
I2_ORACLE_HOME=D:\\Oracle64\\product\\12.1.0\\client_1
I2_ORACLE_HOST=sl1psadevdb2v.jdadelivers.com
I2_ORACLE_INFO_1=ABPPMGR
I2_ORACLE_INFO_2={E:AES}6AA9880B2F94C92CA09E7665CC4AA76B
I2_ORACLE_INFO_2_XOR=@CQQLFS
I2_ORACLE_INFO_3=PSADVDB
I2_ORACLE_INFO_4=
I2_ORACLE_JAR=D:\\Oracle64\\product\\12.1.0\\client_1\\jdbc\\lib\\ojdbc7.jar
I2_ORACLE_PORT=1521
I2_PLATFORM_HOME=
I2_WEBCLIENT_TYPE=NoWeb
I2_WEBLOGIC_BASE_APP=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1\\web\\base
I2_WEBLOGIC_DOMAIN_HOME=C:\\bea\\user_projects\\domains\\mydomain
I2_WEBSPHERE_APPNAME=
I2_WEBSPHERE_APPNAME_BASE=base
I2_WEBSPHERE_CONTEXTROOT=
I2_WEBSPHERE_CONTEXTROOT_BASE=/base
I2_WEBSPHERE_HOME=C:\\Program Files\\IBM\\WebSphere\\AppServer
I2_WEBSPHERE_INSTALLABLE=
I2_WEBSPHERE_NODE=
I2_WEB_SERVER_PORT=22246
INSTALLER_UI=SWING
USER_INSTALL_DIR=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1


i need to update all the value..

can anyone pls help me on this


See More: Need to update the property file using Batch script

Reply ↓  Report •

#1
January 30, 2020 at 23:15:11
✔ Best Answer
I think the (excess) parentheses might have muddled things. Also, there is no instance of "install_prod" in your sample file,, and no assignment of a value to %install_prod%
in your code. Making the best of it, here's this:

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set INSTALL_PROD=------------ TEST replace install jank
(FOR /f "usebackq delims=" %%a IN ("pry") DO (
FOR /f "tokens=1* delims==" %%g IN ("%%a") DO (
IF /i "%%g"=="INSTALL_PROD" (
ECHO %%g=%INSTALL_PROD%
) ELSE (
ECHO %%a
)
)
)
)>newf
::---------- end
I plugged in a dummy to trigger the install_prod swap, as you can see, and made the filenames and paths simple for testing. hope this helps.


Reply ↓  Report •
Related Solutions


Ask Question