set ws=createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
set file1=fso.opentextfile("a.txt")
s=file1.readall
file1.close
n=len(s)
set file2=fso.opentextfile("b.txt")
i=1
do while file2.atendofstream<>true
b=file2.read(1)
if b=mid(s,i,1) then
i=i+1
if mid(s,i,2)=vbcrlf then sm=sm&vbcrlf
else
sm=sm&b
end if
loop
file2.close
set file=fso.createtextfile("c.txt")
file.write sm
file.close
ws.run "c.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
set src=123456
set dst=1123ab4c5sgserg6
set/atmp_0=0,tmp_1=0
call :los
for /l %%i in (0,1,%tmp_0%) do (
call :appa !src:~%%i,1! %%dst:~!tmp_1!,1%% %%i
set/a tmp_1+=1
)
echo %str%!dst:~%tmp_1%!
pause
goto :eof
:appa
if "%~1" equ "%~2" goto :eof
set str=%str%%2
set /a tmp_1+=1
call :appa %~1 %%dst:~%tmp_1%,1%% %tmp_1%
goto :eof
:los
if not "!src:~%tmp_0%,1!" == "" set /a tmp_0+=1&&goto los
set/a tmp_0-=1
goto :eof
Originally posted by ming6747 at 2007-12-21 07:31 PM:
很谢谢2楼和3楼给我的答案
希望看到的答案是批处理 而不是VBS脚本语言和高级语言编的...
嘿嘿,各位,看到好加点分哇,Q币就免了
SETLOCAL ENABLEDELAYEDEXPANSION
set /p src=<a.txt
set /p dst=<b.txt
set src=123456
set dst=1123ab4c5sgserg6
set/atmp_0=0,tmp_1=0
call :los
for /l %%i in (0,1,%tmp_0%) do (
call :appa !src:~%%i,1! %%dst:~!tmp_1!,1%% %%i
set/a tmp_1+=1
)
echo %str%!dst:~%tmp_1%! >c.txt
pause
goto :eof
:appa
if "%~1" equ "%~2" goto :eof
set str=%str%%2
set /a tmp_1+=1
call :appa %~1 %%dst:~%tmp_1%,1%% %tmp_1%
goto :eof
:los
if not "!src:~%tmp_0%,1!" == "" set /a tmp_0+=1&&goto los
set/a tmp_0-=1
goto :eof
[ Last edited by everest79 on 2007-12-22 at 10:45 AM ]