|
|
发表于 2013-3-25 22:33:16
|
显示全部楼层
- @echo off
- SetLocal EnableDelayedExpansion
- ::
- :: 设置文本
- ::
- set Text_A="a.txt"
- set Text_B="b.txt"
- ::
- :: 把文本B每一行保存为变量
- ::
- set n=0
- for /f "usebackq delims=" %%a in (%Text_B%) do (
- set /a n += 1
- set .!n!.=%%a
- )
- ::
- :: 修改文本A
- ::
- set n=0
- set TempFile=.tmp%random%
- (
- for /f %%a in (' findstr /n .* %Text_A% ') do (
- set LineText=
- set /p LineText=
-
- if /i "!LineText:~0,5!" == "name=" (
- set /a n += 1
- for %%a in (.!n!.) do set LineText=name=!%%a!
- )
-
- echo,!LineText!
- )
- ) <%Text_A% >%TempFile%
- move %TempFile% %Text_A%
- start "" %Text_A%
复制代码 |
|