>I used a slightly different syntax:
>for /f "tokens=*" %i in ('date /t') do echo %i
>However, I got identical results to the raw command, with the exception that
>leading white-space was deleted (as expected). I suspect this is caused by
>locale differences, although I did try a variety of different settings on my
>machine, and could not get the two results to differ.
I have tried a variety of regional settings and the two approaches never match
(for 'date /t' or for 'time /t'). Even the suppression of the leading "0" in the
month is odd, since it's not exactly whitespace. Regardless of my regional
settings, 'date /t' always gives yyyy while the FOR approach always gives yy.
I'd really like to know what's going on. FOR is clearly not parsing what would
be stdout, yet, whatever FOR is parsing IS being partially formatted ... it gets
the correct separators. Have you tried it with 'time /t' ... with FOR, the
seconds magically show up.
FOR's command output parsing seems to be a rather generic thing ... giving you
exactly what's expected except in these two cases. I'd like to know what's going
on programatically. As little as I can figure it out, it would seem difficult to
duplicate this behavior on purpose.
Here are more, further simplified versions of the tests. At this moment, my
regional settings were MM-dd-yy and hh:mm:ss (so: why no "ss" in (a), why "yyyy"
in (c), why not "04" in (d)?)
a. v:\> time /t
19:44
19:45:02
c. v:\> date /t
Wed 04-01-1998
Wed 4-01-98
- Vince
___
Vincent Fatica
Syracuse University Mathematics
http://barnyard.syr.edu/~vefatica/