求dos批处理程序,每运行完一次能将1.txt的第二行数字部分自动加一(其他行不变),并替换1.txt文档
1.txt内容如下:aaa123456789012bbb000000000000ccc111111111111...
1.txt内容如下:
aaa 123456789012
bbb 000000000000
ccc 111111111111 展开
aaa 123456789012
bbb 000000000000
ccc 111111111111 展开
展开全部
第2行如果一定是bbb的话,LS代码OK。
@echo off
SetLocal EnableDelayedExpansion
(set/p.=<1.txt&echo=!.!)>2.txt
For /f "skip=1 tokens=1,2" %%i in (1.txt) do (
set n=%%j&set m=%%i
if "%%j"=="000000000000" (set n=1&goto A)
for /l %%a in (0,1,11) do (
if "!n:~%%a,1!" neq "0" (
set c=%%a
call Set /a n=%%n:~!c!,12%%+1
goto A
)))
:A
set n=00000000000!n!&set n=!n:~-12!
echo !m! !n!>>2.txt
more +2 1.txt>>2.txt
move 2.txt 1.txt
pause
@echo off
SetLocal EnableDelayedExpansion
(set/p.=<1.txt&echo=!.!)>2.txt
For /f "skip=1 tokens=1,2" %%i in (1.txt) do (
set n=%%j&set m=%%i
if "%%j"=="000000000000" (set n=1&goto A)
for /l %%a in (0,1,11) do (
if "!n:~%%a,1!" neq "0" (
set c=%%a
call Set /a n=%%n:~!c!,12%%+1
goto A
)))
:A
set n=00000000000!n!&set n=!n:~-12!
echo !m! !n!>>2.txt
more +2 1.txt>>2.txt
move 2.txt 1.txt
pause
展开全部
@echo off&SetLocal EnableDelayedExpansion
(For /f "tokens=1,2" %%i in (1.txt) do (
If "%%i"=="bbb" (
Set n=%%j
Set /a n+=1
echo %%i !n!
) else (
echo %%i %%j
)
))>2.txt
del 1.txt
ren 2.txt 1.txt
pause
(For /f "tokens=1,2" %%i in (1.txt) do (
If "%%i"=="bbb" (
Set n=%%j
Set /a n+=1
echo %%i !n!
) else (
echo %%i %%j
)
))>2.txt
del 1.txt
ren 2.txt 1.txt
pause
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询