Jeremy,

Yes, unfortunately this is only NT and Win2000 in this syntax. In fact, in
Win2000 there is an even simpler form... %DATE% is a dynamic environment
variable which expands to the current date in the local format, so you could
simply have:

set dateserial=%DATE:~10,4%%DATE:~7,2%%DATE:~4,2%

or even compressing the whole thing into a single line:

ren daily.log %DATE:~10,4%%DATE:~7,2%%DATE:~4,2%.log

use "help set" for more details of the syntax.

On Win95 /98 (I don't know about Millenium) you can still do it using the
FOR statement, but date doesn't accept /T so you have to mess around using
echo. | date > txt file then adding .txt files together, and all in all I
wouldn't start from there! (I don't use any of these 95/98/ME so don't take
this as gospel)

Regards

Simon West
Webmaster
Somerset County Council
County Hall Taunton
Somerset TA1 4DY
E-Mail:         mailto:[EMAIL PROTECTED]
Web:            http://www.somerset.gov.uk 
Voice:          +44 (01823) 355905
Fax:            +44 (01823) 355554




-----Original Message-----
From: Jeremy Wadsack [mailto:[EMAIL PROTECTED]]
Sent: 09 January 2001 16:11
To: [EMAIL PROTECTED]
Subject: Re: [analog-help] Renaming a file to include a datestamp
automatically




Simon West wrote:

> I know you have had a lot of answers on this one, but you CAN do it with
> batch files...
>
> @echo off
> for /F "tokens=1,2" %%d in ('date /T') do set day=%%d & set date=%%e
> set yyyy=%DATE:~6,4%
> set mm=%DATE:~3,2%
> set dd=%DATE:~0,2%
> set dateserial=%yyyy%%mm%%dd%
>
> will create the dateserial environment variable as 20010109 today. It is a
> fairly simple matter to adjust this to most formats, but I think that is
> what you wanted, without resorting to Perl.

Thanks Simon. I've never been fully aware of the complete for syntax, so I
missed this possibility. However, I think this only works on NT (and 2000?),
right?


Jeremy Wadsack
Wadsack-Allen Digital Group


------------------------------------------------------------------------
This is the analog-help mailing list. To unsubscribe from this
mailing list, send mail to [EMAIL PROTECTED]
with "unsubscribe" in the main BODY OF THE MESSAGE.
List archived at http://www.mail-archive.com/[email protected]/
------------------------------------------------------------------------
------------------------------------------------------------------------
This is the analog-help mailing list. To unsubscribe from this
mailing list, send mail to [EMAIL PROTECTED]
with "unsubscribe" in the main BODY OF THE MESSAGE.
List archived at http://www.mail-archive.com/[email protected]/
------------------------------------------------------------------------

Reply via email to