%~tI Expands %I to the date and time of file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
darioit
Posts: 230
Joined: 02 Aug 2010 05:25

%~tI Expands %I to the date and time of file

#1 Post by darioit » 11 Aug 2010 05:41

This attribute is used to expand date and time of file.

The time in this format is hh.mm

But if I prefer time in format hh.mm.ss how can I get this value?

Thanks in advance
Dario

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: %~tI Expands %I to the date and time of file

#2 Post by aGerman » 11 Aug 2010 07:26

Think you can't change the time format.
You could use a small included VBScript.

Code: Select all

@echo off &setlocal
set "file=c:\your\file\full\name.ext"

>"%temp%\tmp.vbs" echo WScript.Echo WScript.CreateObject("Scripting.FileSystemObject").GetFile(WScript.Arguments(0)).DateLastModified
for /f "delims=" %%a in ('cscript //nologo "%temp%\tmp.vbs" "%file%"') do set "DateTime=%%a"
del "%temp%\tmp.vbs"

echo %DateTime%
pause


Regards
aGerman

Post Reply