我想使用批处理脚本生成属性文件,其中文件内的数据将以增量方式增加。我必须生成 10 个属性文件,其中数据以增量方式更改。
我有一个属性文件,abpp_deploy.property
其中的数据如下所示:
CHOSEN_INSTALL_SET=DEPLOYER
I2_ABPP_BASE_WEB_URI=base
I2_ABPP_BRE_PATH=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1\\bre
I2_ABPP_HOME=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1
I2_APPSERVER_PORT1=2000
I2_APPSERVER_PORT2=15444
I2_APP_FOLDER_NAME=SOP_-_SEMS
I2_CIS_HOME=
I2_DATABASE_TYPE=Oracle
I2_DATA_POPULATION="","Skip automatic schema creation and data population."
I2_DATA_POPULATION_TEXT_2=Create schema and populate with solution data.
I2_DATA_POPULATION_TEXT_3=Skip automatic schema creation and data population.
I2_DB2_DRIVER=com.ibm.db2.jcc.DB2Driver
I2_DB2_HOME=C:\\Program Files\\IBM\\SQLLIB
I2_DB2_HOST=DB2_HOST
I2_DB2_INFO_1=
I2_DB2_INFO_2=
I2_DB2_INFO_2_XOR=
I2_DB2_INFO_3=
I2_DB2_INFO_4=
I2_DB2_JARS=C:\\Program Files\\IBM\\SQLLIB\\java
I2_DB2_JAR_1=db2jcc.jar
I2_DB2_JAR_2=db2jcc_license_cu.jar
I2_DB2_PORT=50000
I2_DEPLOY_JAR=SEMS.jar
I2_DEPLOY_JAR_PATH_OF_SELECTED_FILE=D:\\Installer\\jdaplatform-2017.1.0.25-windows\\abpp\\installers
I2_DEPLOY_TYPE=STANDALONE
I2_DEPLOY_WEBCLIENT=
I2_EMAIL_ENABLED=
[email protected]
I2_EMAIL_SMTP_HOST=smtp.mycompany.com
[email protected]
I2_ENCRYPT=true
I2_INSTALL_PROD=Prod
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
在这里我必须增加数据,就像第一个文件的值一样
USER_INSTALL_DIR=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1 I2_WEB_SERVER_PORT=22246
但将生成的第二个文件具有如下值:
USER_INSTALL_DIR=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs2
I2_WEB_SERVER_PORT=2224`
类似地,每次生成 10 个文件,其值都会改变。
我已经创建了一个环境文件Batchenv.bat
,它将通过一个 test.bat 文件调用
******************test.bat file code *****************
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
call %~dp0\Batchenv.bat
set sourcedir=C:\Users\1026478\Desktop\local
set envFile=%sourcedir%\Batchenv.bat
IF EXIST %envFile% (
call %envFile%
) else (
echo "Error:::::Environment file missing."
exit /b 0
)
IF NOT EXIST %sourcedir%\abpp_deploy.Property (
echo "ERROR: Property file does not exist or is not readable in below path.\n"
echo %sourcedir%
exit /b 1
)
ECHO Env File check completed.
set "file_app=%sourcedir%\Batchenv.bat"
For /L %%A IN (1,1,1) DO (
ECHO %%A
set VAR1=%%A
For /F "usebackq delims=" %%a in ("%file_app%") do (
set VAR=%%a
For /F "tokens=1* delims= " %%G IN ("!VAR!") DO (
set NODE_VAR=%%G
echo %%G %%H
echo %%H|findstr /I /C:"JDAv2017_SEMs1"
echo %%H>>newfile_!VAR1!.Property
)
)
)
:: newfile.txt now contains a modified version.
:: This line will overwrite the original
::MOVE /y newfile.Property "%sourcedir%\abpp_deploy.Property"
GOTO :EOF
REM (for /F "delims=" %%F in (version-test.properties) do echo %%F | findstr /c:"test1=" /c:"test2=" /c:"test3=" /c:"test4=" >nul && (echo %%F | for /F "delims==" %%L in ('more') do @echo %%L=) || echo %%F) > build-new.txt
*****************Batchenv.bat************************
@echo off
SET CHOSEN_INSTALL_SET=DEPLOYER
SET I2_ABPP_BASE_WEB_URI=base
SET I2_ABPP_BRE_PATH=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1\\bre
SET I2_ABPP_HOME=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1
SET I2_APPSERVER_PORT1=2000
SET I2_APPSERVER_PORT2=15444
SET I2_APP_FOLDER_NAME=SOP_-_SEMS
SET I2_CIS_HOME=
SET I2_DATABASE_TYPE=Oracle
SET I2_DATA_POPULATION="","Skip automatic schema creation and data population."
SET I2_DATA_POPULATION_TEXT_2=Create schema and populate with solution data.
SET I2_DATA_POPULATION_TEXT_3=Skip automatic schema creation and data population.
SET I2_DB2_DRIVER=com.ibm.db2.jcc.DB2Driver
SET I2_DB2_HOME=C:\\Program Files\\IBM\\SQLLIB
SET I2_DB2_HOST=DB2_HOST
SET I2_DB2_INFO_1=
SET I2_DB2_INFO_2=
SET I2_DB2_INFO_2_XOR=
SET I2_DB2_INFO_3=
SET I2_DB2_INFO_4=
SET I2_DB2_JARS=C:\\Program Files\\IBM\\SQLLIB\\java
SET I2_DB2_JAR_1=db2jcc.jar
SET I2_DB2_JAR_2=db2jcc_license_cu.jar
SET I2_DB2_PORT=50000
SET I2_DEPLOY_JAR=SEMS.jar
SET I2_DEPLOY_JAR_PATH_OF_SELECTED_FILE=D:\\Installer\\jdaplatform-2017.1.0.25-windows\\abpp\\installers
SET I2_DEPLOY_TYPE=STANDALONE
SET I2_DEPLOY_WEBCLIENT=
SET I2_EMAIL_ENABLED=
SET [email protected]
SET I2_EMAIL_SMTP_HOST=smtp.mycompany.com
SET [email protected]
SET I2_ENCRYPT=true
SET I2_INSTALL_PROD=Prod
SET I2_JDK_HOME=D:\\Java8\\jdk1.8.0_181
SET I2_LICENSE_FILE=D:\\license\\PSA100417.lic
SET I2_LICENSE_FILE_LOCATION=D:\\license
SET I2_LICENSE_FILE_NAME=PSA100417.lic
SET I2_ORACLE_DRIVER=oracle.jdbc.driver.OracleDriver
SET I2_ORACLE_HOME=D:\\Oracle64\\product\\12.1.0\\client_1
SET I2_ORACLE_HOST=sl1psadevdb2v.jdadelivers.com
SET I2_ORACLE_INFO_1=ABPPMGR
SET I2_ORACLE_INFO_2={E:AES}6AA9880B2F94C92CA09E7665CC4AA76B
SET I2_ORACLE_INFO_2_XOR=@CQQLFS
SET I2_ORACLE_INFO_3=PSADVDB
SET I2_ORACLE_INFO_4=
SET I2_ORACLE_JAR=D:\\Oracle64\\product\\12.1.0\\client_1\\jdbc\\lib\\ojdbc7.jar
SET I2_ORACLE_PORT=1521
SET I2_PLATFORM_HOME=
SET I2_WEBCLIENT_TYPE=NoWeb
SET I2_WEBLOGIC_BASE_APP=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1\\web\\base
SET I2_WEBLOGIC_DOMAIN_HOME=C:\\bea\\user_projects\\domains\\mydomain
SET I2_WEBSPHERE_APPNAME=
SET I2_WEBSPHERE_APPNAME_BASE=base
SET I2_WEBSPHERE_CONTEXTROOT=
SET I2_WEBSPHERE_CONTEXTROOT_BASE=/base
SET I2_WEBSPHERE_HOME=C:\\Program Files\\IBM\\WebSphere\\AppServer
SET I2_WEBSPHERE_INSTALLABLE=
SET I2_WEBSPHERE_NODE=
SET I2_WEB_SERVER_PORT=22246
SET INSTALLER_UI=SWING
SET USER_INSTALL_DIR=D:\\JDA\\JDA2017_3\\config\\JDAv2017_SEMs1
我能够生成具有常量值的文件,但无法增量地改变它。