Hello,
I am trying to create a batch script which is a simple find but I want to have the result in the order that the string exists.
Let me give an example. The following is what I have at the moment. which scans the file for ERROR then ouputs any occurrences. then moves onto the next string: WARNING and outputs any differences and so on. But when I review the output file it bears no resemblence to order of the input file since it is search for each string in turn.
%~d1
cd "%~p1"
find /N "ERROR" %1 > c:\temp.lst
find /N "WARNING" %1 >> c:\temp.lst
find /N "already on the library" %1 >> c:\temp.lst
find /N "another string with spaces in it" %1 >> c:\temp.lst
output
ERROR: first error
ERROR: second error
WARNING: first warning
WARNING: second warning
what I really want it do is do a find and give an idea of where chronologically the issue occurred e.g to have output
ERROR: first error
WARNING: first warning
ERROR: second error
WARNING: second warning
I know I can use the find command and list the strings like this and it will do what I want for strings without any spaces.
find /N "ERROR WARNING" %1 > c:\temp.lst
But the problem I have had is when I have a string I am searching for with spaces e.g. "already on the library"
I cannot do
find /N "ERROR WARNING already on the library" %1 > c:\temp.lst
because it will search for already, on, the, library separately.
Can someone please help with what to do here?
Thanks in advance,
Rex
DOS Find command for multiple strings with spaces
Moderator: DosItHelp
Re: DOS Find command for multiple strings with spaces
This should work - it needs the case insensitive switch due to findstr bugs.
findstr /i /c:"ERROR" /c:"WARNING" /c:"already on the library" /C:"another string with spaces in it" %1 >> c:\temp.lst
Edited error: changed find to findstr
findstr /i /c:"ERROR" /c:"WARNING" /c:"already on the library" /C:"another string with spaces in it" %1 >> c:\temp.lst
Edited error: changed find to findstr
Re: DOS Find command for multiple strings with spaces
Thank you so much for your swift reply. I did try the above but it gave me the message invalid switch. But I tried alternatively with findstr and it worked perfectly.
Thanks again
findstr /i /c:"ERROR" /c:"WARNING" /c:"already on the library" /c:"another string with spaces in it" %1 >> c:\temp.lst
Thanks again

findstr /i /c:"ERROR" /c:"WARNING" /c:"already on the library" /c:"another string with spaces in it" %1 >> c:\temp.lst