bat 执行svn同步分支目录脚本2(传参数后)

@echo off
CHCP 936

set paramNum=0
set result=1

for %%c in (%*) do (
    set /a paramNum+=1
)
if %paramNum% == 0 (
    echo "参数为空"
    set result=1
    goto result
) else (
    goto work_handle
)

%正式处理%
:work_handle
set path_dir=E:\fy\pack_xxkp\branch\
set on_dir=E:\fy\pack_xxkp\server_trunk
set curr_dir=%cd%
set log_dir=%curr_dir%\log
set log_file=%log_dir%\%date:~0,4%-%date:~5,2%%date:~8,2%.log
set curr_time=%time:~0,2%:%time:~3,2%:%time:~6,2%

set workDir=
set serverDir=

svn update "%on_dir%"
echo 更新源目录-----:%on_dir% 
echo %curr_time%  %on_dir%--------------------更新源目录>> %log_file%
if not exist %log_dir% (       
    md %log_dir%  
)
setlocal enabledelayedexpansion
for %%c in (%*) do (
    set workDir=%path_dir%%%c
    set serverDir=!workDir!\server
    if EXIST !serverDir! (
        echo !curr_time!  !workDir!开始>> %log_file%
        svn update !workDir!
        rd /s /Q !serverDir!
        md !serverDir!
        xcopy %on_dir% !serverDir! /e /q /y
        echo [xcopy] !serverDir!
        cd /d !serverDir!
        for /f "eol=M tokens=1,2 delims= " %%i in ('svn st') do (
            if "%%i" == "?" (
                svn add "%%j"
            )else if "%%i" == "A" (
                svn add "%%j"
            )else if "%%i" == "!" (
                svn del "%%j"
            )
        )
        set curr_time=!time:~0,2!:!time:~3,2!:!time:~6,2!
        echo !curr_time! !workDir!"<<<"完成!!>> %log_file%
        echo 完成========================----------------------》》》》%%c
    ) else (
        echo !workDir!未找到目录
        echo !curr_time!  !workDir!未找到目录>> %log_file%
        if %paramNum% == 1 (
    goto result
        )
    )
)
echo %curr_time%  =================全部处理完成========================>> %log_file%
set result=0
goto result

:result
    if %result% == 0 (
        echo 处理成功
    ) else (
        echo =========处理失败!!!
    )
 

你可能感兴趣的:(bat日常收集,batch,windows脚本)