部分批处理备忘

@echo off
::-------------------------------------------------------
set nodeIp=
set startPort=
set zoneId=
set runDir=
set dbIp=
set dbPort=3306
set dbUser=root
set dbPasswd=test
set dbName=
set memCacheIp=
set memCachePort=11211
set clientIp=
set outerIp=
set emailAddr=""
::-------------------------------------------------------
set lastkey=
set needExit=0
::-------------------------------------------------------
:loop
if "%1" == "" ( goto :begin ) else (
	if "%lastkey%" == "" (
		set lastkey=%1
	) else (
		set %lastkey%=%1
		set lastkey=
	)
)
shift
goto :loop

:checkKeyNull
if %needExit% equ 1 goto :eof
if "%2" == "" (
	echo "%1 should not be null"
	set needExit=1
)
goto :eof

:setNullKeyVal
if %needExit% equ 1 goto :eof
if "%3" == "" (
	set tmp=%1
	set %tmp%=%2
)
goto :eof

:begin
call :checkKeyNull nodeIp %nodeIp% 
call :checkKeyNull startPort %startPort%
call :checkKeyNull zoneId %zoneId%
call :checkKeyNull runDir %runDir%
call :checkKeyNull dbName %dbName%
call :setNullKeyVal dbIp %nodeIp% %dbIp% 
call :setNullKeyVal memCacheIp %nodeIp% %memCacheIp% 
call :setNullKeyVal clientIp %nodeIp% %clientIp% 
call :setNullKeyVal outerIp %nodeIp% %outerIp% 
if %needExit% equ 1 goto :end

for /f "tokens=*" %%a in ('dir /b win\*.cfg') do (
	call :producefile %%~na
)
goto :eof

:producefile
set filename=%1
set filetype=%filename:~0,-4%
set filedir=%runDir%\%filetype%
md %filedir%
copy /Y win\%filename% %filedir%\%filename%\
goto :eof


:end
exit /b 0

 

转载于:https://my.oschina.net/u/659405/blog/752606

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值