Solved How to view n lines in txt files in subdirectories dos batch

January 20, 2015 at 18:31:14
Specs: Windows 7
Hello. I am trying to view specific lines of txt files within many sub-directories and output the lines to errors.txt. I have code that almost works, but it will not look in the sub-directories.

(@for /f "tokens=2* delims=[]" %%a in ('find /v /n "" ^*.txt ^|findstr /i /s "^\[1\] ^\[2\] ^\[4\]"') do @echo %%a) > errors.txt

Thanks.

message edited by jared125


See More: How to view n lines in txt files in subdirectories dos batch

Report •


#1
January 20, 2015 at 21:47:33
✔ Best Answer
Here are a couple of options:


@echo off & setlocal
(for /r %%a in (*.txtt) do (
echo %%a
find /v /n "" <%%a | findstr /r ".*\[[124]\].*"
))>\where\iwant2b\errors.txt

that seemed to work ok.

findstr /s /n ".*" *.txt | findstr /r ".*:[124]:.*">>errors.txt

also seemed to work. The filepathname is included in the output


Report •

#2
January 21, 2015 at 06:52:04
Thanks for the quick response it helped me figure it out. Here is what works:

@echo off & setlocal
(for /r %%a in (*.txt) do (
echo %%a
find /v /n "" <%%a | findstr /r "^\[10\] ^\[11\] ^\[12\]"
))>errors.txt

Thanks again!!


Report •
Related Solutions


Ask Question