WinRAR command-line arguments:!WinRAR!a"!rarto!" "!from!"The path within the compressed file can be specified with-EP,-EP1, etc., but it seems that it is not good to specify only the folder containing the file, presumably:-ep3 includes the drive name,-EP2 does not include the drive, test EP EP1 are no folders, directly is the file;------------------- Winrar.exe parameter-ag[format]: Specify a time string for the file name of the compressed package; (%date:~0,4%%date:~5,2%%date:~8,2%)
-R: Along with subfolders;
Call:
set "from=D:\source_asp\crm\crm\*"
set "to=D:\source_asp\crm"
set "name=crmasp"
call "backup.bat" "!from!" "!to!" "!name!"
pause
Backup.bat:
@rem 作用:压缩文件,用来备份
@rem 用法:call "backup.bat" "!from!" "!to!" "!name!"
@rem 其他:
@rem 2015/12/01 周二 15:54:55.85
@echo off&SetLocal EnableDelayEdexpansion
rem set "from=D:\sourse_klmy\crm\*.pbl"
rem set "to=D:\sourse_klmy\源码\crm"
rem set "name=crm"
set "from=%~1"
set "to=%~2"
set "name=%~3"
set winrar="C:\Program Files\WinRAR\WinRAR.exe"
set "mdate=!date!"
set "mdate=!mdate:/=-!"
set "mdate=!mdate:\=-!"
rem set "mdate=%date:~0,4%%date:~5,2%%date:~8,2%"
set /p comment=输入附加说明:
if defined comment (
set "rarto=!to!\!name!_!mdate!_!comment!.rar"
) else (
set "rarto=!to!\!name!_!mdate!.rar"
)
if exist "!rarto!" (
echo !rarto! 已经存在..
pause>nul
exit
)
echo!rarto!
!winrar! a -r "!rarto!" "!from!"
if %errorlevel% == 0 (
echo 压缩成功......
) else (
echo 压缩失败....
)
echo;&echo;
From for notes (Wiz)
01. Back Up CRM source code