Computing.Net > Forums > Programming > Batch scripting

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.

Batch scripting

Reply to Message Icon

Name: koned
Date: March 26, 2009 at 12:08:23 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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 ABCD

I am trying for a batch script which extracts only data with latest date and also having string OUTPUT and INPUT.

Thanks in advance



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 26, 2009 at 22:23:18 Pacific
Reply:

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


0

Response Number 2
Name: koned
Date: March 27, 2009 at 06:39:04 Pacific
Reply:

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)


0

Response Number 3
Name: Mechanix2Go
Date: March 27, 2009 at 22:44:17 Pacific
Reply:

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


0

Response Number 4
Name: koned
Date: March 28, 2009 at 16:01:46 Pacific
Reply:

Yes Exactly


0

Response Number 5
Name: Mechanix2Go
Date: March 29, 2009 at 03:24:33 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: koned
Date: March 29, 2009 at 08:58:26 Pacific
Reply:

Thanks thought, you would give some solution but does not look like.


0

Response Number 7
Name: Mechanix2Go
Date: March 29, 2009 at 23:04:51 Pacific
Reply:

What do you need extracted from the file?


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

M2


0

Response Number 8
Name: koned
Date: March 30, 2009 at 09:21:22 Pacific
Reply:

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.


0

Response Number 9
Name: Mechanix2Go
Date: March 30, 2009 at 09:48:06 Pacific
Reply:

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


0

Response Number 10
Name: koned
Date: March 30, 2009 at 10:23:08 Pacific
Reply:

Thank you very much for your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Batch to copy and increme... batch file for Documents ...



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: Batch scripting

batch script to parse filenames www.computing.net/answers/programming/batch-script-to-parse-filenames/15286.html

Batch Script Help Needed www.computing.net/answers/programming/batch-script-help-needed/14475.html

batch script www.computing.net/answers/programming/batch-script/14086.html