2

(Platform: Win7) I am able to directly save the output of what "findstr" command find.

findstr /S /N "#ifdef" *.cpp >D:\Test\123.txt

and the output looks like this:

dealloc.cpp:3:#ifdef 1

But I just can't to make it save in the format like

file name:dealloc.cpp line:3

how do I add the string "file name:"before the file found by findstr command and add string "line" before that number? Thanks in advance!

Heidi
  • 31
  • 1
  • 4

1 Answers1

4

If this is what you want you can add redirection on the second line:

for /f "tokens=1,2 delims=:" %%a in ('findstr /S /N "#ifdef" *.cpp') do (
   (echo(file name:%%a line:%%b)
)
npocmaka
  • 55,367
  • 18
  • 148
  • 187
  • 2
    This will have to be adjusted if the specified search path includes the drive letter because of the extra `:` – dbenham Apr 20 '16 at 11:51