@echo off
set SOURCR_PATH=D:\1
set dd=%date:~,10%
set tt=%time:~,8%
echo %dd% %tt%
set TARGET_PATH=D:\%dd%
echo %TARGET_PATH%
if exist %SOURCR_PATH% (
echo 将要复制的目录是D:\1
)
if not exist %SOURCR_PATH% (
echo 将要复制的目录D:\1不存在
goto end
)
if exist %TARGET_PATH% (
rd /q /s %TARGET_PATH%
echo %TARGET_PATH%已经存在,为了复制已成功将其删除
)
if not exist %TARGET_PATH% (
mkdir %TARGET_PATH%
echo %TARGET_PATH%创建成功
)
xcopy %SOURCR_PATH% %TARGET_PATH% /s /e
echo 备份成功
:end
pause
打印:
2012-07-17 17:09:35
D:\2012-07-17
将要复制的目录是D:\1
D:\2012-07-17已经存在,为了复制已成功将其删除
D:\2012-07-17创建成功
D:\1\10.txt
D:\1\11\11.txt
复制了 2 个文件
备份成功
请按任意键继续. . .