Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
I am beginner in batch scripting and have very less idea about scripting.Please help me.
I want to extract data from a file which has format
03/25/09 08:29:35 INFO OUTPUT
03/25/09 09:29:35 INFO INPUT
02/23/09 04:30:35 INFO OUTPUT
2/23/09 11:30:35 XYZ ABCDI am trying for a batch script which extracts only data with latest date and also having string OUTPUT and INPUT.
Thanks in advance

I assume that strings like this represent the date:
2/23/09
You'll have some real challenges, not least because of mm/dd/yy layout.
If this is something like a log file I wonder why 'earlier' lines are after 'later' lines. But maybe I'm guessing wrong.
Maybe a bigger sample of file will help.
=====================================
If at first you don't succeed, you're about average.M2

Yeah this is a log file.I just gave a sample file.But the actual file looks like this
3/24/09 13:54:23 INFO Incoming file (path of file)
03/24/09 14:00:28 INFO Incoming file (path of file)
03/24/09 14:00:28 INFO Forwarded (path of file)
03/24/09 14:00:30 INFO Incoming file (path of file)
03/25/09 07:03:02 INFO Incoming file (path of file)
03/25/09 07:03:02 INFO Forwarded (path of file)
03/25/09 07:03:04 INFO Incoming file (path of file)

Well, you might get lucky today. You want 2 lines, the latest INPUT and the latest OUTPUT, right?
=====================================
If at first you don't succeed, you're about average.M2

Now I'm lost. I see neither INPUT nor OUTPUT in your posted file.
While we're at it, is the first date really m issing it's leading zero? Hopefully not; just lost in the pasting.
=====================================
If at first you don't succeed, you're about average.M2

What do you need extracted from the file?
=====================================
If at first you don't succeed, you're about average.M2

I want to extract lines with latest date and having string "Incoming file" and "forwarded file".I can extract lines only with latest dates without mentioning string but just to avoid any unwanted stuff I want to add string.I hope I am clear this time.Please help me out.

This will get the appropriate lines into separate files. Then you can use your method to get latest dates.
==========================
find /i "forwarded" < my.log > fwd
find /i "Incoming file" < my.log > inc
=====================================
If at first you don't succeed, you're about average.M2

![]() |
Batch to copy and increme...
|
batch file for Documents ...
|

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