部分批处理备忘

原创
2016/09/28 11:57
阅读数 43
@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

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部