Put date in a txt file.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is a batchfile I am using today.

@echo off
for /F "tokens=1-5" %%a in ('now.exe') do set MyDate=%%e-%%b-%%c

printmig -b C:\%MyDate%.cab \\server

So now I also would like to generat a different txt file containing the date
when this batchfile runs.
I am running this from a w2k workstation. I could use the date /t command
but I don´t get the right format I wish too. My output should be yyyyy-mm-dd.
When using a w2k workstation the output looks like Fr yyyy-mm-dd. I am sure
it is an easy coomand but I can´t get it right.
Could anyone help me??

Regards
Henrik
 
This is a batchfile I am using today.

@echo off
for /F "tokens=1-5" %%a in ('now.exe') do set MyDate=%%e-%%b-%%c

printmig -b C:\%MyDate%.cab \\server

So now I also would like to generat a different txt file containing the date
when this batchfile runs.
I am running this from a w2k workstation. I could use the date /t command
but I don´t get the right format I wish too. My output should be yyyyy-mm-dd.
When using a w2k workstation the output looks like Fr yyyy-mm-dd. I am sure
it is an easy coomand but I can´t get it right.
Could anyone help me??

Regards
Henrik

Use the %#LogDate% variable. It is always yyyymmdd.

In your specific case:

CALL ntlib.cmd /Init /Quiet
SET MyDate=%#LogDate:~0,4%-%#LogDate:~4,2%-%#LogDate:~6,2%
printmig -b C:\%MyDate%.cab \\server


For additional color-keyed examples, see
(http://TheSystemGuard.com/MtCmds/GetValue/GetLogDate).

#LogDate is part of the Advanced NT/2K/XP/K3 Command Library. Code written
using this library performs CONSISTENTLY across Windows NT, 2000, XP and
Server 2003.

Request your copy at (http://ntlib.com).
It is FREE for personal or commercial use.

*******
-tsg

/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(http://TheSystemGuard.com/default.asp#MasterCommandList)
 
This is a batchfile I am using today.

@echo off
for /F "tokens=1-5" %%a in ('now.exe') do set MyDate=%%e-%%b-%%c

printmig -b C:\%MyDate%.cab \\server

So now I also would like to generat a different txt file containing the date
when this batchfile runs.
I am running this from a w2k workstation. I could use the date /t command
but I don´t get the right format I wish too. My output should be yyyyy-mm-dd.
When using a w2k workstation the output looks like Fr yyyy-mm-dd. I am sure
it is an easy coomand but I can´t get it right.
Could anyone help me??

Regards
Henrik

For /f "Tokens=2" %%x in ('date /t') do (
@echo %%x
)

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top