1. 程式人生 > >VS指令碼自動備份工程

VS指令碼自動備份工程

@echo off
title 備份VS工程
@echo off&setlocal enabledelayedexpansion
set projectname=UDS
rem 建立資料夾
set /p inputname="輸入壓縮版本:"
if "%inputname%"=="" (
    set timehour=%time:~0,1%
    if !timehour! EQU 0 (
        set timetemp=%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%
    ) else
( set timetemp=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2% ) set inputname=!timetemp! ) set drarname="%projectname%-%inputname%.rar" if exist %drarname% ( echo "壓縮檔案已經存在請刪除後在重試" pause exit ) set backupdir=%projectname%-backup if not exist %backupdir%
( md "%backupdir%" ) rem 驗證 :rd /s /Q %backupdir% if not exist "%backupdir%" ( echo "建立資料夾失敗" pause exit ) set backupname=UDS_Client set dpath="%cd%\%backupdir%\%backupname%\" set spath="%cd%\%backupname%" xcopy %spath% %dpath% /V /Y /S /EXClUDE:unbackup.txt if %errorlevel% NEQ 0 ( echo "替換失敗" pause
exit ) set backupname=UDS set dpath="%cd%\%backupdir%\%backupname%\" set spath="%cd%\%backupname%" xcopy %spath% %dpath% /V /Y /S /EXClUDE:unbackup.txt if %errorlevel% NEQ 0 ( echo "替換失敗" pause exit ) set backupname=Debug set dpath="%cd%\%backupdir%\%backupname%\" set spath="%cd%\%backupname%" if exist %spath% ( xcopy %spath% %dpath% /V /Y /S /EXClUDE:unbackup.txt if %errorlevel% NEQ 0 ( echo "替換失敗" pause exit ) ) set backupname=Release set dpath="%cd%\%backupdir%\%backupname%\" set spath="%cd%\%backupname%" if exist %spath% ( xcopy %spath% %dpath% /V /Y /S /EXClUDE:unbackup.txt if %errorlevel% NEQ 0 ( echo "替換失敗" pause exit ) ) set backupname=UDS.sln set dpath="%cd%\%backupdir%\%backupname%" set spath="%cd%\%backupname%" copy /V /Y %spath% %dpath% if %errorlevel% NEQ 0 ( echo "替換失敗" pause exit ) rem 壓縮檔案 if not exist "%cd%\修改日誌.txt" cd.>修改日誌.txt if not exist "%cd%\修改日誌.txt" ( echo "建立檔案失敗" pause exit ) set rpath="%cd%\%backupdir%" "C:\Program Files\WinRAR\WinRAR.exe" -ep1 a %drarname% %rpath% -z"%cd%\修改日誌.txt" if %errorlevel% NEQ 0 ( echo "壓縮檔案失敗" pause exit ) rd /s /Q %backupdir%