Computing.Net > Forums > Programming > Dos script to search into .txt file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dos script to search into .txt file

Reply to Message Icon

Name: vishuonly4u
Date: July 17, 2008 at 08:39:10 Pacific
OS: 2k
CPU/Ram: 1.8
Comment:

Team,

Every day we get some bunch of .txt files.

I want to search into a log files(*.txt) for a string DONE, with help of Dos script.

Could you please help me in this.
How to search for DONE keyword in the file.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 17, 2008 at 10:05:51 Pacific
Reply:

for %%T in (*.txt) do find "DONE" %%T


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: rprgrmr
Date: July 17, 2008 at 17:56:56 Pacific
Reply:

Look into findstr.

findstr /?

A very simple example, a case insensitive search:

findstr /I done C:\*.txt

Omit the /I for a case sensitive search.

Also can redirect output to another file and open it in notpad:

findstr /I done C:\*.txt > c:\DONE.log & notepad c:\DONE.log

Many options. The FOR command can be useful, too.

rprgrmr


0

Response Number 3
Name: Mechanix2Go
Date: July 17, 2008 at 23:25:43 Pacific
Reply:

There is no findstr in DOS.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: vishuonly4u
Date: July 28, 2008 at 12:50:09 Pacific
Reply:

Team ,
I want to ask u some more in this.
"
for %%f in ("*.txt") do (
echo "%%f" | find %%f /c "<reply>done</reply>"
if !errorlevel! EQU 0 set /a count=count+1
)"
Using this code I am able t count the file where I have this lines.
But now I want to count the files where I dont have this code.
Like :=
<reply>done</reply> is the Positive reply state.
But when we have error (-ve state) during that time we get
<reply>NOT DONE</reply> or
<reply>The error information</reply>

So understand when we have error I am planing to search inside the file for error message... but its not a common .. so I cant put that into the search string pattern.

So I am planing to scan the files which DONT HAVE this lines.
<reply>done</reply>.

I dont know how to do this??
Could you please help me on this


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Dos script to search into .txt file

Dos script search in .txt file P-2 www.computing.net/answers/programming/dos-script-search-in-txt-file-p2/16746.html

How to Grab the first file in dir www.computing.net/answers/programming/how-to-grab-the-first-file-in-dir/18259.html

Scripts to search for a text in a view source www.computing.net/answers/programming/scripts-to-search-for-a-text-in-a-view-source/19961.html