@echo off
rem [usage] CMD src dist_dir
FOR /F "tokens=2,3,4 delims=- " %%i in ("%date%") do set now=%%i_%%j_%%k
echo %now%
FOR /F "tokens=1,2,3 delims=:. " %%i in ("%time%") do set now=%now%#%%i_%%j_%%k
echo %now%
mkdir %2
set bakdir=%2/%1_%now%
echo 正在备份到%bakdir%...
xcopy %1 %bakdir% /S /Y
echo 备份完毕.
pause
自动备份到含时间戳的目录,如
备份/XXX_2006_04_16#1_00_31
rem [usage] CMD src dist_dir
FOR /F "tokens=2,3,4 delims=- " %%i in ("%date%") do set now=%%i_%%j_%%k
echo %now%
FOR /F "tokens=1,2,3 delims=:. " %%i in ("%time%") do set now=%now%#%%i_%%j_%%k
echo %now%
mkdir %2
set bakdir=%2/%1_%now%
echo 正在备份到%bakdir%...
xcopy %1 %bakdir% /S /Y
echo 备份完毕.
pause
自动备份到含时间戳的目录,如
备份/XXX_2006_04_16#1_00_31