----^--->
/\

//\\
//The\
/Sy
stem\
////
Guard
\

In the mount of the LORD it shall be seen. Genesis 22:14

GetLogTime

Booming Or Fuming? | MasterCatalog | ntlib (FREE) | NTCmdLib | MtCmds | Scripts | Almost Free | TheGuardBook | Help

 

Types of
.Mount/\Commands

.CrystalClear | .ExactName | .ExitELn | .GetValue | .ifCondition | .ifELn | .IsPattern | .ListValue | .NetValue | .NowValue | .RedirRapids | .ReliableReporting | .RestoreValue | .SetELn | .ValueEcho

.GetValue
Series

  .GetCD | .GetDate | GetDirSize | GetDirSizeM | GetFree | GetFreeM | GetIPAddr | GetIPGateway | GetIPMask | GetLogDate | GetLogTime | GetLogTimeP | GetMac | GetNic | GetOS | GetRole | GetTempFile | GetTime | GetTimeP

.GetLogTime

Description

  1. Displays the current time as hhmnss, regardless of the local time format
  2. Saves the value in #LogTime

Syntax

At the Command Prompt

C:\>. GetLogTime    
C:\>%.GetLogTime%    

In a Script

%.GetLogTime%    

Parameters and Switches

none

   

Errorlevels and Output Variables

Display to
STDOUT

 

Value of
#LogTime

 

Error
Level

  Description of Result

070530

 

070530

  n/a   Display current time as hhmnss

Examples, Notes and Instructions

NT
2K
XP
K3
C:\GuardPost>%.GetLogTime%
070530
C:\GuardPost>SET #LogTime
#LogTime=070530

  • Output is displayed to STDOUT
  • To suppress console display, use

    %.GetLogTime% %.Quiet%

{errorlevel and output variable(s) will still be available}


Related .Mount/\Commands, #Constants, $Functions, :Procedures

Resource

  Short Description
.GetLogDate   Display current date as yyyymmdd, regardless of the local date format
.GetLogTimeP   Display current time as hhmnsshs, regardless of the local time format

!GuardNotes

How to rename a file using the current time

01. %.GetLogTime% %.Quiet%
02. REN "FileName.ext" "%#LogTime%.ext"

This will rename FileName.ext to hhmnss.ext

^
/
!\

Always put file names "in quotes" to avoid errors when any part of the file name or it's path contain embedded spaces or reserved characters.

How to rename a file using the current time and date

01. (%.GetLogTime% & %.GetLogDate%) %.Quiet%
02.
REN "FileName.ext" "%#LogDate%-%#LogTime%.ext"

How to rename multiple files using the current time and date

01. (%.GetLogTime% & %.GetLogDate%) %.Quiet%
02.
FOR %%A IN (FileSpec [...]) DO @(
03.    REN "%%~dpnA" "%%~dpnA_%#LogDate%-%#LogTime%%%~xA"
04. )

%%~dpnA = Drive, Path and FileName only (no extension)
%%~xA   
= Extension only, including the . prefix (".doc")

The above example will append "_yyyymmdd-hhmnss" to each filename matching the FileSpec while preserving the correct extension.

For example, if FileSpec = "*.doc", each file matching *.doc will be renamed to
 "OriginalDocumentName_20030101-070530.doc"


K

E

Y

Common Commands INTERNAL External /SWITCH Parameter Help text AddonTool
Mounted Commands .Mount/\Command CmdShorthand #Constant $FUNCTION :Procedure !GuardNote
Operating Systems NT/2K/XP/K3 NT Only NT/2K 2K Only 2K/XP XP Only XP/K3 K3 Only 2K/XP/K3

.GetValue
Series

  .GetCD | .GetDate | GetDirSize | GetDirSizeM | GetFree | GetFreeM | GetIPAddr | GetIPGateway | GetIPMask | GetLogDate | GetLogTime | GetLogTimeP | GetMac | GetNic | GetOS | GetRole | GetTempFile | GetTime | GetTimeP
/\
//\\
//
The\
/Sy
stem\
////
Guard
\
COME ON UP WITH US!
and
Congratulations On Your Decision
to
RISE ABOVE
THE REST!

^
/
!\
/LIB\

TheSystemGuard.com [Revised: 2007-03-29]
Copyright © 1995-2007, JWC
Computer Communications,
All Rights Reserved, Worldwide.
 Disclaimer       Privacy       About Us       More


Communication Is Business!

We Master It With Knowledge!

^
/
.\
/M^C\