Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
karzer
- Posts: 21
- Joined: 17 Jul 2010 02:56
#1
Post
by karzer » 09 Aug 2011 02:48
Hi, I'm using this script on my server
Code: Select all
type D: \ 09082011.txt | find / c "aborted"
the following problem, every day here consists of a new file, the most recently created file to use this command. How can I do?
Code: Select all
type D: \ ?????. txt | find / c "aborted"
Date created from last
-
dbenham
- Expert
- Posts: 2461
- Joined: 12 Feb 2011 21:02
- Location: United States (east coast)
#2
Post
by dbenham » 09 Aug 2011 22:32
Code: Select all
for /f %%f in ('dir /b /o-d /tw d:\*.txt') do find /c "aborted" %%~ff & goto :quitLoop
:quitLoop
Dave Benham
-
karzer
- Posts: 21
- Joined: 17 Jul 2010 02:56
#3
Post
by karzer » 10 Aug 2011 03:11
Thank you very much for your interest, just want to get some value, how can I do?
I want this value is only
73now I have received results
-
dbenham
- Expert
- Posts: 2461
- Joined: 12 Feb 2011 21:02
- Location: United States (east coast)
#4
Post
by dbenham » 10 Aug 2011 05:21
Sorry - I think
FIND /C "aborted" filename is faster than
TYPE filename | FIND /C "aborted". But I didn't test for differences in output. Just need to revert to your syntax.
Also I reread your requirements and saw you wanted the most recent *.txt
created. I was getting the most recent *.txt
written to. So I changed the DIR option from /TW to /TC.
Here is the fix:
Code: Select all
for /f %%f in ('dir /b /o-d /tc d:\*.txt') do type %%~ff | find /c "aborted" & goto :quitLoop
:quitLoop
Dave Benham
-
karzer
- Posts: 21
- Joined: 17 Jul 2010 02:56
#5
Post
by karzer » 12 Aug 2011 03:50
Problem solved...
Thank you very much for your interest