1.

Solve : Use of for and findstr to copy lines where text string is present?

Answer»

I coded this in a bat file.
for /F "delims=" %%F in ('findstr " Form identifier " D:\EFILING\INPROCESS\sarwklymsgs.log') do copy "%%F" >> D:\EFILING\LOGS\formsids.log
 
Thought it would copy line that contained the findstr text to the end of a text file.
 
Seems to work but all I GET in output text file for each line that contains the findstr text is a line of text saying
The system cannot FIND the file specified.
 
The reason I say it is working is I get one line saying that for each line containing the findstr text.
So findstr is working but the copy has issues.
 
Can someone tell me what is wrong or a better way to code what I am trying to do.
Thank you for your TIME in helping me.
do echo "%%F" >> D:\EFILING\LOGS\formsids.logThis may be enough for what you need to do - the double quotes allow long PATH and filenames with SPACES also.


Code: [Select]findstr " Form identifier " "D:\EFILING\INPROCESS\sarwklymsgs.log" >> "D:\EFILING\LOGS\formsids.log" Quote from: foxidrive on April 22, 2014, 10:39:56 AM

This may be enough for what you need to do - the double quotes allow long path and filenames with spaces also.


Code: [Select]findstr " Form identifier " "D:\EFILING\INPROCESS\sarwklymsgs.log" >> "D:\EFILING\LOGS\formsids.log"
That should run quicker as well.


Discussion

No Comment Found