@echo off
set today=%date:~0,4%%date:~5,2%%date:~8,2%
xcopy /E /I E:\aaa e:\test\%today%
for /f "skip=2" %%i in ('dir /B /O-N E:\test') do rd E:\test\dest\%%i /S /Q
--------------------------代码在上,说明在下--------------------------------
说明:
@echo off
不显示DOS的的提示信息
set today=%date:~0,4%%date:~5,2%%date:~8,2%
定义一个变量today,便于以当前日期备份文件夹
xcopy /E /I E:\aaa e:\test\%today%
将要备份的aaa目录备份至E盘test目录下,以当天日期(如20130822)为名的文件夹中。
for /f "skip=2" %%i in ('dir /B /O-N E:\test') do rd E:\test\%%i /S /Q
循环两天备份
for /f "skip=2"
跳过前两行,如果要循环备7天,就改为=7
dir /B /O-N E:\test
是只显示文件名,且以文件名的倒序排列