Re: Batch File Timestamp

  • Thread starter Thread starter guard
  • Start date Start date
G

guard

I'm trying to create a batch file that will rename another
file and include a timestamp in the file name. For
example, incoming file is named MyTestFile.dat and I want
to rename it to MyTestFile-180623.dat

Any advice would be appreciated I'm sure it's quite a
simple line or two of code. Thanks.

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

For example:

%.GetLogTime%
REN MyTestFile.dat MyTestFile-%#LogTime%.dat

GetLogTime returns hhmnss CONSISTENTLY under NT/2K/XP/K3 and saves this
value in variable %#LogTime%. Output is always the same regardless of
variations in operating systems and regional date/time formats.

See (http://TheSystemGuard.com/MtCmds/GetValue/GetLogTime.htm#GuardNotes)
for more information and a color-keyed example.

*******

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

Some other Get[Value] commands are:

GetLogDate (yyyymmdd)
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. See them all at
(http://TheSystemGuard.com/MtCmds/GetValue)

*******

The complete .Mount/\Command Set contains over 200 commands. These
are extensions to the builtin command set that perform CONSISTENTLY across
NT/2K/XP/K3 and provide self-documenting code for your scripts.

See (http://MountCommands.com) for more information.

*******

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).

*******

All the commands internal to cmd.exe are documented in "Mounted Help" pages
in TheGuardBook (http://TheSystemGuard.com/TheGuardBook/CCS-Int).

This includes a color-keyed page highlighting the differences between all
internal commands in NT/2K/XP/K3.

The "Common Help" from each OS's help screen is also available for
comparison.

*******

-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 
Someone without a real name wrote:

[lots of advertising crap]

Stephen started this thread in microsoft.public.win2000.cmdprompt.admin.
There is absolutly no need to post your advertising messages to 3 other
newsgroups, where nobody can see Stephens first posting.

It seems to me, that you are not interested in helping other people.
You just want to sell your 'products' over the usenet.

Once again: Please stop this.


Juergen


P.S.: You don't use a real name for your postings and even on your web-
site there is no personal name. Do you think people will trust such a
person?
 
Juergen Schwarze said:
Someone without a real name wrote:

[lots of advertising crap]

Stephen started this thread in microsoft.public.win2000.cmdprompt.admin.
There is absolutly no need to post your advertising messages to 3 other
newsgroups, where nobody can see Stephens first posting.

It seems to me, that you are not interested in helping other people.
You just want to sell your 'products' over the usenet.

Once again: Please stop this.


Juergen


P.S.: You don't use a real name for your postings and even on your web-
site there is no personal name. Do you think people will trust such a
person?

You are saying this to someone who continues to hide behind the phony name,
and continues to fail to follow common usenet etiquette. Yet there actually
*are* people associated with that paragon of entrepeneurship, "The System
Guard", one such being:

John D. Zanette
Vice President
JWC Computer Communications
(e-mail address removed)

I hesitated to post the above address, but then realized that it can only be
to their benefit for a real person to receive the complaints that otherwise
are falling on deaf ears, as their behavious here cannot possibly be having
a positive impact on their business.

/Al
 
Back
Top