为 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%* . *