使用debug- @echo off
- Setlocal EnableDelayedExpansion
- Set fs=1.txt
- Set dt=2.txt
- Set tf=db-tmp.txt
- Set lenb=1
- Set "o=>>%tf%"
-
- call :sizehex %fs%
- call :consoledb %fs%
-
- ::scan file1
- %o% echo s 100 %size% 20
- %o% echo q
- start /w debug ^<%tf% ^>db-out.txt
-
- ::edit file1
- call :consoledb %fs%
- for /f "eol=- tokens=2 delims=:" %%a in (db-out.txt) do (
- if defined old (
- set /a len=0x%%a-old-1
- set /a old=0x%%a
- if !len! GTR !lenb! Set /a lenb=len
- ) else (
- set /a old=0x%%a
- )
- %o% echo e %%a
- %o% echo 0A
- )
- %o% echo w
- %o% echo q
- start /w debug ^<%tf%
-
- ::output
- call :fined >%dt%
-
-
- call :sizehex %dt%
- call :consoledb %dt%
-
- ::scan file2
- %o% echo s 100 %size% 0D
- %o% echo q
- start /w debug ^<%tf% ^>db-out.txt
-
- ::edit file2
- call :consoledb %dt%
- for /f "eol=- tokens=2 delims=:" %%a in (db-out.txt) do (
- set /a count+=1,line=count%%6
- if !line! NEQ 0 (
- %o% echo e %%a
- %o% echo 20 20
- )
- )
- %o% echo w
- %o% echo q
- start /w debug ^<%tf%
-
-
-
-
- pause
- del db-???.txt
- goto :eof
-
- :fined
- set reg=%reg%[0-9]
- if %lenb% EQU 0 goto :eof
- set /a lenb-=1
- more %fs%|findstr /b /e %reg%|sort
- call :fined
- goto :eof
-
- :consoledb
- >%tf% cd.
- %o% echo n%1
- %o% echo l
- goto :eof
-
- :sizehex
- set /a size=%~z1/16*10
- goto :eof
复制代码
|