LEARNER
Is there is any way with batch file I can search multiple text files at specific line position if specific text exist, get path output ?
e.g. text in file look as below :
this is sample a file
just for explaining
This is 3rd line
nothing in this line
further there could be so many lines.
nothing to read more
but this last line
I don't know where we can specify in code how to look for "nothing in this" in 4th line.
search for ""nothing in this" in all files in sub folders and get path for each file
and get output like this
C:\TextFolder\newfolder\sample11.txt
C:\TextFolder\newfolder2\sample12.txt
Code is not correct, it is just for example so you can understand what I am trying to do.
Code: Select all
pushd "C:\TextFolder"
FOR /F %%A IN (SAMPLE*.TXT | FINDSTR "nothing in this") DO ECHO %%~DPNXA>>C:\OUTPUT\LIST.TXT
POPD
#2 21 Jul 2013 08:18
foxidrive
Code: Select all
@echo off
for /r "c:\textfolder" %%a in (*.txt) do findstr /n "." "%%a" |findstr /r /i /c:"^4:.*nothing in this.*" >nul && >>output.txt echo %%a
#3 22 Jul 2013 05:01
Aacini
Code: Select all
pushd "C:\TextFolder"
(for /F "delims=:" %%a in ('findstr /S /N /C:"nothing in this" *.txt ^| findstr /C:":4:"') do echo %%a)>C:\OUTPUT\LIST.TXT
popd
#4 22 Jul 2013 11:10
foxidrive
Your use of findstr to process the files in one pass is likely more efficient Aacini though the full path isn't returned here in Win 8.
----------------------------