Batch file help with Findstr

September 5, 2011 at 10:39:50
Specs: Windows 7
I'm trying to create a batch file to read three years of log files.

Sample with highlights of what you are looking for:
[5] Fri 01Jan10 00:05:22 - (nnnnnn) User logged in
[3] Fri 01Jan10 00:06:28 - (nnnnnn) Sending file d:\ftp_sites\database.iss

[02] Sat 01Jan11 00:09:20 - (nnnnnn) User "" logged in
[20] Sat 01Jan11 00:12:42 - (nnnnnn) RETR /software/tools/withtb.exe

Basically i need a findstr string to find the users email address or login, above its and then grab the session ID in (nnnnnn) and find all session ID's with the string Sending file.

Can anyone help?

See More: Batch file help with Findstr

Report •

September 8, 2011 at 15:56:10
First of all I would put them all in the same folder. I am not sure what type of file you have them saved as so I will use plain text files for this example. Here is what I have come up with:

@echo off

findstr /i @ *.txt >> temp.txt
findstr /i ( *.txt >> temp.txt
findstr /i "sending file" ( *.txt >> temp.txt

: the first line will print all of the email address from your files
:the second line will print all of your session ID numbers as long as they are within parentheses
:the third line will search for sending file; the added bracket is to seperate the results into different lines to make it easier to read. I hope this helps

Report •
Related Solutions

Ask Question