Home > Mobile >  findstr ignoring c:/ switch in batch file
findstr ignoring c:/ switch in batch file

Time:07-11

Can someone have a look at this mess please? In my file test.txt I have a line "Coupon (%)" which is parsing into findstr as "Coupon". I have tried another line "Coupon frequency" which is also just parsing as "Coupon".

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 accept the line as a string as I would expect with the findstr /c: switch please? if I use the g:/ switch on the test.txt file it works fine but I need the output to be in the order I specify in the file and g:/ outputs everything in line order which is why I'm using type

Thanks for help

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 or , or ;) hence "Coupon". Using "delims=" selects the entire line for %%t

  • Related