Read the /? help for the FOR command, which explains how to
extract tokens from strings. Typical syntax:
Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
SETLOCAL
FOR /f "tokens=2-4 delims=/ " %%A IN ("%DATE%") DO SET DT=%%A%%B%%C
ECHO. Date=%DT%
====End cut-and-paste (omit this line)
Simulated Win2000 for study/demo use. Cut-and-paste as Batch text file.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects
--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
From email address not checked. Contact us at http://www.allenware.com/
Well, you could pipe it through mtr -o \D+ = ""
where mtr is MiniTrue; not worth installing for the one job, of course;
but worth having in general.
But it would be far better to go for 20050914 - not only is that in
accordance with ISO 8601, but it also accords with a FIPS, and is
manifestly better.
To get the date output in that format, you can use
NOWMINUS f1 j0 r ; software date, as is proper
NOWMINUS ^ f1 j0 r ; software date, as WA prefers !!!
getting NOWMINUS.ZIP from <URL:http://www.merlyn.demon.co.uk/programs/>;
NOWMINUS enables various manipulations and formats of the date (e.g.
last Thursday, as year-quarter-day).
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/>
Thanks, Brian