user3636391
user3636391

Reputation: 11

How to remove filename in findstr output file

I use findstr to search and output my search to another txt file but need to omit the filename, can anyone help pls? Thanks in advance!

My current batch file :- findstr "TEST" *.dat > output.txt

and the result of output.txt with all the filename Doc*.dat(which I need to remove):-

Doc (1).dat:2014-04-15;TEST TECHNOLOGY LTD
Doc (10).dat:2014-04-29;TEST TECHNOLOGY LTD
Doc (11).dat:2014-04-30;TEST TECHNOLOGY LTD
Doc (12).dat:2014-05-02;TEST TECHNOLOGY LTD
Doc (13).dat:2014-05-05;TEST TECHNOLOGY LTD
Doc (14).dat:2014-05-06;TEST TECHNOLOGY LTD

Best Regards, W

Upvotes: 1

Views: 9773

Answers (1)

Stephan
Stephan

Reputation: 56180

findstr writes the filename, when you use wildcards.

Alternatives:

use another command, that doesn't write the filename in the same line as the content:

find "TEST" *.dat |find "TEST" >output.txt

or:

use findstr without wildcards (use a forloop to supply one filename at a time)

for %%i in (*.dat) do findstr "TEST" %%i >>output.txt

Upvotes: 3

Related Questions