If I'm doing more text files, it will take too much time for this script because every text file have more than 500 lines.
This is the sample of input file:-
[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]
I want output like this:-
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
Please let me know what I am doing wrong.