爲 VC6 工作區目錄量身訂做的備份文件的批處理
用法:將代碼保存爲批處理文本文檔例如: Backup.bat 。
前提條件:1) 目標機器已經在默認位置安裝了WINRAR。
2) 操作系統應該在Windows 2000或以上(其它操作系統在修改部分代碼後也可以使用)
代碼如下:
rem 刪除多餘的文件
if exist *.ncb del *.ncb
if exist debug rd debug /s /q
if exist release rd release /s /q
rem 獲取當前目錄名
set current_dir=%cd%
:loop
set current_dir=%current_dir:*/=%
set tmpv=%current_dir:*/=%
if not %tmpv%==%current_dir% goto loop
rem 按時間在上級目錄自動生成當前目錄的備份
"%ProgramFiles%/WinRAR/WinRAR.exe" a -ag -r ../%current_dir%.rar ../%current_dir%*.*
if exist *.ncb del *.ncb
if exist debug rd debug /s /q
if exist release rd release /s /q
rem 獲取當前目錄名
set current_dir=%cd%
:loop
set current_dir=%current_dir:*/=%
set tmpv=%current_dir:*/=%
if not %tmpv%==%current_dir% goto loop
rem 按時間在上級目錄自動生成當前目錄的備份
"%ProgramFiles%/WinRAR/WinRAR.exe" a -ag -r ../%current_dir%.rar ../%current_dir%*.*