Skip navigation

JSI Tip 6934. How do I determine the date/time that a file was modified, using a batch?

In tips 0494, 3579, 3580, and 6933, I parsed a file batch parameter.

The %~t1 syntax will return the date and time that file %1 was modified.

I have scripted GetDTTM.bat to return a call directed environment variable with the date and time that file %1 was modified.

The syntax for using GetDTTM.bat is:

Call GetDTTM.bat FileName DTTM

Where FileName is the fully qualified name of a file, and DTTM is the name of the variable you want set.

GetDTTM.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax: Call GetDTTM FileName DTTM&goto :EOF
set %2=
if not exist %1 @echo File %1 not found.&goto :EOF
set %2=%~t1



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish