Can someone have a look at this mess please?
I have in the file test.txt
a line with the search string Coupon (%)
, but FINDSTR searches just for Coupon
. I have tried another line with search string Coupon frequency
in file test.txt
which results in searching also just for Coupon
.
This is the command line in the batch file:
for /f %%f in ('dir /s /b C:\Users\me\Desktop\script\links\') do for /f %%t in ('type C:\Users\me\Desktop\script\test.txt') do for /f "delims=:" %%a in ('findstr /n /c:"%%t" %%f') do C:\Users\me\Desktop\script\links2.exe %%f %%a && echo %%t
How can I make this command line to use the entire line in file test.txt
as entire search string as I would expect with the FINDSTR /c:
switch please?
It works fine if I use the option /g:
on searching the file test.txt
. But I need the search results output to be in the order in which I specified the search strings in the file test.txt
and /g:
outputs all lines with any of the searched strings in line order of the searched file which is why I'm using TYPE.
CodePudding user response:
You need
... for /f "delims=" %%t in ...
Stands out. Your code will select the first token by default, using the default delimiters (Space or Tab) hence "Coupon". Using "delims=" selects the entire line for %%t