if not exist cont.bat echo @echo off>>cont.bat & set cont=^0>>cont.bat ::这是第一次运行时或cont.bat文件被删除时才执行的代码
call cont.bat ::获取备份次数
del /f /q cont.bat >nul
set /a cont=%cont%+1 ::加次数
echo @echo off>>cont.bat
echo set cont=^%cont%>>cont.bat
set ran=%random% ::获取随机数(防止文件夹同名)
mkdir "F:\%date%%ran%" ::创建目录
echo 正在备份中……
copy "C:\program\xxx\*.*" "F:\%date%%ran%" ::将所有的在C:\program\xxx中的文件全部复制到这个文件夹里面
cls
echo 第%cont%次备份完成!目录名:%date%%ran%
pause>nul
注意:这个cont.bat文件不要删,否则会重新计数
不清楚你的实际文件/情况,仅以问题中的说明及猜测为据复制粘贴到记事本,另存为xx.bat,编码选ANSI@echo off
rem 按当前月份备份和打包文件夹
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
set "oldfolder=D:\"
set "newfolder=E:\"
set "exefile=C:\Program Files\WinRAR\WinRAR.exe"
if "%oldfolder:~-1%" equ "\" set "oldfolder=%oldfolder:~,-1%"
if "%newfolder:~-1%" equ "\" set "newfolder=%newfolder:~,-1%"
if not exist "%exefile%" (echo"%exefile%" no found&goto end)
>"%tmp%\v.v" echod=date:WSH.echo right(year(d),4) ^& right("0" ^& month(d),2) ^& right("0" ^& day(d),2)
for /f %%a in ('cscript -nologo -e:vbscript "%tmp%\v.v"') do set d=%%a
set "year=%d:~,4%"&set "month=%d:~4,2%"&set "day=%d:~-2%"
for %%a in ("1=一" "2=二" "3=三" "4=四" "5=五" "6=六" "7=七" "8=八" "9=九" "10=十" "11=十一" "12=十二") do (
for /f "tokens=1* delims==" %%b in ("%%~a") do set _%%b=%%c
)
if not exist "%oldfolder%\%month%月账单" (echo"%oldfolder%\%month%月账单" no found&goto end)
if not exist "%newfolder%\%month%月账单 %year%-%month%-%day%\" (
md "%newfolder%\%month%月账单 %year%-%month%-%day%\"
)
set "backupfile=%newfolder%\%month%月账单 %year%-%month%-%day%\%year%-%month%-%day%.rar"
"%exefile%" a -r -ep1 -y "%backupfile%" "%oldfolder%\%month%月账单\*"
:end
echo%#% +%$%%$%/%@% %z%
pause
exit
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)