T
thinktwice
/////mytest.txt///////////////////////////////
type1:AA
type1:BB
type2:CC
type2D
type3:EE
///////////////////////////////////////////////////
setlocal enabledelayedexpansion
set typepattern="type2,type3" <-----here i means i want to search
all the types that match type2 or type3
for /f "tokens=1,2* delims=:" %%i in ('findstr /c:TYPE= C:
\mytest.txt') do @(
set mytype=%%i
set tmptype=%typepattern%
:loop
for /f "tokens=1,2* delims=," %%u in ("!tmptype!") do (
if /i "%%u"=="!mytype!" (set %%j=match) else (set tmptype=%%v&goto
loop) )
)
i expect this batch file could achieve this:
set CC=match
set DD=match
set EE=match
but it doesn't work. anything wrong in my batch?
type1:AA
type1:BB
type2:CC
type2D
type3:EE
///////////////////////////////////////////////////
setlocal enabledelayedexpansion
set typepattern="type2,type3" <-----here i means i want to search
all the types that match type2 or type3
for /f "tokens=1,2* delims=:" %%i in ('findstr /c:TYPE= C:
\mytest.txt') do @(
set mytype=%%i
set tmptype=%typepattern%
:loop
for /f "tokens=1,2* delims=," %%u in ("!tmptype!") do (
if /i "%%u"=="!mytype!" (set %%j=match) else (set tmptype=%%v&goto
loop) )
)
i expect this batch file could achieve this:
set CC=match
set DD=match
set EE=match
but it doesn't work. anything wrong in my batch?