- 帖子
- 3
- 积分
- 106
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2009-3-4
|
回复 2# yhcfsr
@set total_times=0
@echo off
set "SrcDir=%cd%\1"
set "desDir=c:\Backup5"
if exist c:\backup5 (
echo "已经存在文件夹"
)
else (
md c:\backup5
)
set/p "times=Please enter the number of create copies:"
for /f "delims=" %%a in ("%SrcDir%") do set "name=%%~nxa"
for /l %%a in (1,1 %times%) do (
set/a total_times+=1&setlocal enabledelayedexpansion
if !total_times! lss 10 ( xcopy "%SrcDir%" "%desDir%\%name%0!total_times!" /I /E
/Y ) else (
xcopy "%SrcDir%" "%desDir%\%name%!total_times!" /I /E /Y)
endlocal
)
rem 记录总共运行次数到BAT文件
(for /f "delims=" %%a in ('type "%0"') do if not defined first (
echo;@set total_times=%total_times%&set first=1) else (echo;%%a))>"tp"
move /y "tp" "%0">nul
if not exist
pause
我加了一个目录判断但总提示有错误麻烦高手帮忙看一下 |
|