While the subject line is the primary question, there are several secondary questions here also. So getting on the point, the following very-simple batch file:
Produces the following output:
So the first and (probably most important in terms of what I am trying to accomplish) question is: What happened to what should have been the first line output? Specifically, it should be:
12/11/2011 22:36 88,822 QMGZZ.txt
And the second and third (and probably equally important in terms of what I am trying to accomplish) questions are: "Why is the final value of "I" zero outside of the loop after the loop finishes?" And if the implication of what appears to be the case from the above is the only thing I can think of that it might be, is there any way to "export" the final value of "I" outside of the "Do" loop?
The fourth question is: "How and why does "I" start out with the value "2" in what would seem must be the first line of the output?
And the fifth question is: How come there is that line whose "count" is "0" (I honestly don't see any way that a zero can be output for the "line number", ever)?
I will note two things that might be called "independent results" produce the following:
"@Echo %@Files[Q*]" simply yields the number "9".
The listing resulting from the command: "Dir /K /M Q*" contains exactly 9 lines, what you would expect given the results of "%@Files[Q*]" function, above.
What am I not understanding?
- Dan
Code:
@Echo Off
SetLocal
Set I=0
Dir /K /M Q* | ^
Do Line in @CON (
Set /A I+=1
@Echo I: %I Line: %Line
)
@Echo The Final Value of I: %I
EndLocal
Quit 0
Produces the following output:
Code:
I: 2 Line: 10/22/2011 18:47 326 QQQZZ.NotNowBTM
I: 3 Line: 2/17/2011 3:30 18,943 QRSTZZ.txt
I: 4 Line: 12/19/2011 1:20 324 Quad.btm
I: 5 Line: 12/21/2011 8:08 2,152 QWETX.btm
I: 6 Line: 12/20/2011 16:17 7,417 QWETX.txt
I: 7 Line: 12/21/2011 1:19 4,393 QWETX.V2011-12-21-01-19.btm
I: 8 Line: 12/21/2011 2:01 1,742 QWETX.V2011-12-21-02-01.btm
I: 9 Line: 12/12/2011 15:14 1,697 QWRTZZ.txt
I: 0 Line:
The Final Value of I: 0
So the first and (probably most important in terms of what I am trying to accomplish) question is: What happened to what should have been the first line output? Specifically, it should be:
12/11/2011 22:36 88,822 QMGZZ.txt
And the second and third (and probably equally important in terms of what I am trying to accomplish) questions are: "Why is the final value of "I" zero outside of the loop after the loop finishes?" And if the implication of what appears to be the case from the above is the only thing I can think of that it might be, is there any way to "export" the final value of "I" outside of the "Do" loop?
The fourth question is: "How and why does "I" start out with the value "2" in what would seem must be the first line of the output?
And the fifth question is: How come there is that line whose "count" is "0" (I honestly don't see any way that a zero can be output for the "line number", ever)?
I will note two things that might be called "independent results" produce the following:
"@Echo %@Files[Q*]" simply yields the number "9".
The listing resulting from the command: "Dir /K /M Q*" contains exactly 9 lines, what you would expect given the results of "%@Files[Q*]" function, above.
What am I not understanding?
- Dan