如果要处理的替换只有前二十行和後十行,
请问将文本分成三区来处理会不会比较快呢?
先将A区前二十行替换完毕,
不会动到的B区用>输出到A区後面,
最後十行C区放B区後。
这样做超快,但超过1mb,批处理会当掉,- @echo off
- @setlocal enabledelayedexpansion
- del *.txt
- echo %1>drive.txt
- (for /f "tokens=1* delims=:" %%d in ('findstr /n .* drive.txt') do (
- set drive=%%e"
- set drive=!drive:~0,2!
- ))
- (for %%f in (%*) do (
- call echo !drive!%%%%f
- )>>t1.txt)
-
- ECHO\1.HassM09 2.HassM09T 3.HassM09TOM99 4. 5.HG83
- ECHO\11.M09 12.M09T 13.M09TOM99 16.M8M09 18.M57
- set /p prog="prog is "
-
- if %prog% equ 3 (call D:\LGetCode\TransCode\HassM09TOM99.bat) else (
-
- echo\ no mode
- )
-
- PAUSE
- del *.txt
- del *.doc
复制代码 HassM09TOM99.bat- @echo off
- setlocal enabledelayedexpansion
-
- (for /f "tokens=1* delims=:" %%g in ('findstr /n .* t1.txt') do (
- set "file=%%h"
- ECHO]************************************
- echo]starting %%h
- setlocal enabledelayedexpansion
- set "tool=%%h"
- set "tool=!tool:~-4,1!"
- set "dec=!file:~-5,1!"
- if !dec! gtr 9 set dec=0
- set num=!dec!!tool!
-
- rem *******
- rem First20Line
- rem *******
- echo]First20
- (for /l %%a in (1 1 20) do (
- set str=&set /p str=
- echo]!str!
- ))<%%h >First20.txt
-
-
- REM ***************************************************
- REM deal First20Line
- REM ***************************************************
- echo]dealFirst20
- (for /f "tokens=1* delims=:" %%i in ('findstr /n .* First20.txt') do (
- set "line=%%j"
- setlocal enabledelayedexpansion
- if "!line!"=="" (echo\!line!) else (
- for %%n in (!num!) do set "line=!line:O1000=O00%%n!"
- for %%n in (!num!) do set "line=!line:O0100=O00%%n!"
- for %%n in (!num!) do set "line=!line:O0001=O00%%n!"
-
- for %%m in (!tool!) do set "line=!line:(SC POSTPROCESSOR A.I.C TAICHUNG)=T%%mM6!"
- set "line=!line:/G05.1 Q1= !"
- set "line=!line:.M09=.!"
- for %%l in (!tool!) do set "line=!line:H1=H%%l!"
- echo\!line!
- endlocal
- )))>back.txt
- move back.txt First20.txt
-
- rem ********
- rem delFirst20
- rem ********
- more +20 %%h>WithoutFirst20.txt
- findstr .* WithoutFirst20.txt >> First20.txt
-
- rem *********************************************************
- rem Last20Line
- rem *********************************************************
- echo]last20line
- sort /+4096 First20.txt /o Reverse.txt
- (for /l %%a in (1 1 20) do (
- set str=&set /p str=
- echo]!str!
- ))<Reverse.txt >Last20Rev.txt
- sort /+4096 Last20Rev.txt /o Last20.txt
-
- (for /f "tokens=1* delims=:" %%i in ('findstr /n .* Last20.txt') do (
- set "line=%%j"
- setlocal enabledelayedexpansion
- if "!line!"=="" (echo\!line!) else (
-
- set "line=!line:/G05.1 Q0= !"
- set "line=!line:M30=M99!"
- echo\!line!
- endlocal
- )))>back.txt
- move back.txt Last20.txt
-
-
- rem *******
- rem delLast20Line
- rem *******
- ECHO]delLast20Line
- sort /+4096 First20.txt /o ABrev.txt
- more +20 ABrev.txt>WithoutCrev.txt
- sort /+4096 WithoutCrev.txt /o WithoutC.txt
- findstr .* Last20.txt >> WithoutC.txt
- move WithoutC.txt %%h
-
- rem ********
- rem End Main Loop Do and For
- rem ********
- echo]%%h is done
-
- ))
复制代码
|