How to FIND more than one string?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tinfanide
Posts: 114
Joined: 05 Sep 2011 09:15

How to FIND more than one string?

#1 Post by tinfanide » 27 Feb 2012 04:15

I wanna extract two pieces of info, for example,

1. BIOS
2. Computer Name

Two questions (see comments below)
Consider this, please:

criterion.log
BIOS
Computer Name


Code: Select all


@ECHO OFF


:: How can I use
:: TYPE systeminfo >> C:\systeminfo.log

   systeminfo > C:\systeminfo.log

   FOR /F "tokens=* delims=" %%G In (C:\criterion.log) DO (
      :: How can I
                :: TYPE file | FIND string1 string 2 >> newfile
      TYPE C:\systeminfo.log | FIND "%%G" >> C:\extracted.log      

   )

PAUSE



Last question:
How can I do the above task without the for loop in the criterion log?

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: How to FIND more than one string?

#2 Post by foxidrive » 27 Feb 2012 04:47

Use findstr with the /c switch, twice.

tinfanide
Posts: 114
Joined: 05 Sep 2011 09:15

Re: How to FIND more than one string?

#3 Post by tinfanide » 27 Feb 2012 07:19

Nice one. Thanks.

Post Reply