Today's date in a batch file

  • Thread starter Thread starter Spin
  • Start date Start date
S

Spin

At the end of a batch file that I run once per week, I want it to copy a
file called Updated<today's date>.txt into a folder that I specify.
<today's date> must be the actual date that my batch was run, in this
format: 20030905

Does any guru have the answer for this?
 
Does any guru have the answer for this?
Using univdate.bat from tip 4835 in the 'Tips & Tricks' at
http://www.jsiinc.com

WOOOOW... I truely honestly have NO IDEA how the heck that univdat.bat puppy
works! Man, maybe they should have an NG just for people who can do crazy
things with batch files!!

Thanks.
 
There are! BTW, if you are into batch scripting, follow Phil Robyn's
posts in these groups. He's pretty remarkable!
 
Phil Robyn is THE MAN!!!!

--

Ricardo M. Urbano - W2K/NT4 MVP said:
There are! BTW, if you are into batch scripting, follow Phil Robyn's
posts in these groups. He's pretty remarkable!
 
At the end of a batch file that I run once per week, I want it to copy a
file called Updated<today's date>.txt into a folder that I specify.
<today's date> must be the actual date that my batch was run, in this
format: 20030905

Under Windows NT/2K/XP/K3, this can be done in two self-documenting lines of
code using
Mount/\Commands.

%.GetLogDate%
COPY Updated%#LogDate%.txt DestinationFolder

*******

..GetLogDate CONSISTENTLY displays the date as yyyymmdd, regardless of the
local date format. This value is also saved to variable %#LogDate% and is
always 8 digits. For a color-keyed example, see
(http://TheSystemGuard.com/MtCmds/GetValue/GetLogDate.htm)

*******

GetLogDate is part of the .GetValue Series of Mount/\Commands.

Some other Get[Value] commands are:

GetLogTime (hhmnss)
GetIPAddr (nnn.nnn.nnn.nnn)
GetMac (xx-xx-xx-xx-xx-xx)
GetFree (free space on current drive in bytes)
GetRole (Server/Wkstn)

Each one displays to the console AND saves the value to a variable for
further processing. Examples at (http://TheSystemGuard.com/MtCmds/GetValue)

*******

Notes:

1. .Mount/\Commands are constructed using ONLY builtin
commands common to all four platforms (NT/2K/XP/K3).
There is NO BINARY CODE, only scripting commands!
2. .M/\C's are NOT case sensitive. Mixed case is used
for visual clarity only.
3. The (FREE) Advanced NT/2K/XP Command Library (ntlib.cmd)
provides over 50 sample Mount/\Commands to assist with
writing and documenting cross-platform scripts.
You can obtain it at http://ntlib.com.

*******

-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 
There are! BTW, if you are into batch scripting, follow Phil Robyn's
posts in these groups. He's pretty remarkable!

There are? Like... where? (There's so many NGs here... I guess I must have
missed that one!)

Thanks.
 
Todd, I assume you meant to say you "can't *get* the batch file to run
properly"??

I would put a carat in front of the redirection so that the interpreter
doesn't redirect the entire line instead of just the command you want
redirected:

robocopy source destination /switches && call univdate && @echo %date% %
time ^> MyFolder\Updated%yy%%mm%%dd%.txt
My batch file has to be all one line.

I use the robocopy command in the first part of the line (robocopy part
works fine) but I can't the batch file to run properly:

robocopy source destination /switches && call univdate && @echo %date% %
time > MyFolder\Updated%yy%%mm%%dd%.txt
 
Not on the MS servers. You gotta search for them on your ISP's NNTP
servers.
 
Not on the MS servers. You gotta search for them on your ISP's NNTP

Mmm... don't think my ISP *has* any NNTP servers... (I could be wrong I
guess.) Anyway, I was just wondering... does anyone have something similar
to UnivDate.bat what works on times instead of dates?

Thanks.
 
Invisible said:
Mmm... don't think my ISP *has* any NNTP servers... (I could be wrong I
guess.) Anyway, I was just wondering... does anyone have something similar
to UnivDate.bat what works on times instead of dates?

Thanks.

Create a new thread. Hopefully, Phil Robyn will see it...
 
...does anyone have something similar
to UnivDate.bat what works on times instead of dates?

The Mount/\Commands GetLogTime works CONSISTENTLY on NT/2K/XP/K3 regardless
of the regional time settings.

Syntax is:

%.GetLogTime%

This will display hhmnss and save it to a variable named #LogTime.

See a color-keyed example at
(http://TheSystemGuard.com/MtCmds/GetValue/GetLogTime.htm)

*******

-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 
Ricardo said:
Create a new thread. Hopefully, Phil Robyn will see it...

Hi, Ricardo!

So do you understand what it is that 'Invisible' wants? 'Works on
times instead of dates' means what?

P.S.: Thanks for the compliment!
 
Phil said:
Hi, Ricardo!

So do you understand what it is that 'Invisible' wants? 'Works on
times instead of dates' means what?

P.S.: Thanks for the compliment!

--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l

Hi Phil. I think he's referring to the univdate script that Jerold
referenced earlier in the thread. He must be looking for something that
will insert times as well as dates into strings.

So, how was that wedding? ;->
 
Ricardo said:
Hi Phil. I think he's referring to the univdate script that Jerold
referenced earlier in the thread. He must be looking for something that
will insert times as well as dates into strings.

So, how was that wedding? ;->

The wedding was great! But all the time we were in Portland, we
had three huge meals/banquets per day . . . I'm not used to eating
so heavily. The 10.5-hour drive straight back from Portland to
Berkeley was also interesting. :-)
 
Phil said:
The wedding was great! But all the time we were in Portland, we
had three huge meals/banquets per day . . . I'm not used to eating
so heavily. The 10.5-hour drive straight back from Portland to
Berkeley was also interesting. :-)

--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l

Sounds like my kind of affair! Food and drink; what more could a boy
ask for?!
 
Ricardo said:
Sounds like my kind of affair! Food and drink; what more could a boy
ask for?!

Maybe a new Ferrari Enzo and enough pocket money to change the oil a few
times (at $60/quart)? ;-)
 
...does anyone have something similar
to UnivDate.bat what works on times instead of dates?

The Mount/\Commands GetLogTime works CONSISTENTLY on NT/2K/XP/K3 regardless
of the regional time settings.

Syntax is:

%.GetLogTime%

This will display hhmnss and save it to a variable named #LogTime.

See a color-keyed example at
(http://TheSystemGuard.com/MtCmds/GetValue/GetLogTime.htm)

*******

-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 
Back
Top