如果我调用吹口本,会花费太多时间。任何人请简化

问题描述 投票:0回答:0

如果我正在做更多的文本文件,这个脚本会花费太多时间,因为每个文本文件都有超过 500 行。

这是输入文件的样本:-

[MHMEM:"ID-01 (COLUMN-C10)"]
[LDDAT:0000000," ","01","T10",1,11,11,1150,"15N",600,420,130,600,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","02","T10",1,36,36,2600,"99165",420,820,130,0,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","03","T10",1,36,36,2100,"99165",170,820,130,0,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","04","T10",1,72,72,1375,"99165",200,420,130,0,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","05","T20",1,16,16,4425,"26",1000,245,3160,40,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]

我想要这样的输出:-

CALL :Find "15N" "51"
CALL :Find "99165" "998"
CALL :Find "26" "26k"
[MHMEM:"ID-01 (COLUMN-C10)"]
[LDDAT:0000000," ","01","T10",1,11,11,1150,"51",600,420,130,600,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","02","T10",1,36,36,2600,"998",420,820,130,0,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","03","T10",1,36,36,2100,"998",170,820,130,0,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","04","T10",1,72,72,1375,"998",200,420,130,0,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
[LDDAT:0000000," ","05","T20",1,16,16,4425,"26k",1000,245,3160,40,0,0,0,0,0,0,0, , ,0,0,0, , ,0,0,0]
:Find <input1> <input2> <Notes>
@echo off & setlocal EnableDelayedExpansion
for %%a in (*.txt) do (
    if exist "%%~na.tmp" del "%%~na.tmp"
    set "inputfile=%%~nxsa"
    for /f "delims=" %%b in (!inputfile!) do (
    for /f "tokens=1-30,* delims=," %%c in ("%%b") do (
    set "text=%~2"
    set "Note=%~3"
    if "%%k"=="" (
        echo %%b>>"%%~na.tmp"
    ) else (
    if not "%%k"==""%~1"" (
        echo %%b>>"%%~na.tmp"
    ) else (
    if "%%k"==""%~1"" set "Code=!text!" & set "L=!Note!" (
        echo %%c,%%d,%%e,%%f,%%g,%%h,%%i,%%j,"!Code!",%%l,%%m,%%n,%%o,%%p,%%q,%%r,%%s,%%t,%%u,%%v,!L!,,0,0,0,,,0,0,0]>>"%%~na.tmp"
            )
            )
        )
    )
    del "%%~nxa"
    ren "%%~na.tmp" "%%~nxa"        
)       
exit/b
goto :eof

请让我知道我做错了什么。非常感谢。

windows batch-file conditional-statements
© www.soinside.com 2019 - 2024. All rights reserved.