7

How can I display the time stamp of a file with seconds,

(creation date/time, modified date/time, and access date/time. All, with seconds).

from the command line?

barlop
  • 25,198

2 Answers2

17

You could use PowerShell to get that information.

  1. Start PowerShell from the startmenu
  2. Use:
Get-ChildItem <<File or Folder>> -Force | Select-Object FullName, CreationTime, LastAccessTime, LastWriteTime, Mode, Length

It will print out the information for you. -Force is used to get items that cannot otherwise be accessed by the user, such as hidden, or system files. Additionally you can use the -Recurse option to recurse into folders.

PS C:\Users\user> Get-ChildItem c:\q\az.png -Force | Select-Object FullName, CreationTime, LastAccessTime, LastWriteTime, Mode, Length

FullName : C:\q\az.png CreationTime : Sun 28 Apr 2013 12:12:59 LastAccessTime : Sun 28 Apr 2013 12:12:59 LastWriteTime : Tue 22 Jul 2008 05:01:47 Mode : -a--- Length : 79248

PS C:\Users\user>

An easy way to recurse into folders and have a file that can be imported into Excel is to use:

Get-ChildItem C:\ProjectX -Force -Recurse | Select-Object FullName, CreationTime, LastAccessTime, LastWriteTime, Mode, Length | Export-Csv c:\temp\ProjectX_files.csv

enter image description here

Heebr
  • 484
1
E:\blah>cscript //nologo filetimes.vbs a.a
Times for file: E:\blah\a.a
Created:  15/12/2014 2:04:22 AM
Modified: 31/05/2016 10:42:31 PM
Accessed: 15/12/2014 2:04:22 AM

contrast with

E:\blah>dir a.a
31/05/2016  10:42 PM            26,990 a.a

(dir only shows one time at a time, e.g. /tw by default, or /tc or /ta can write /t:w e.t.c. see dir /? for other info)

So that vbscript file shows 3 times and seconds and in one command.

Set objFSO = CreateObject("Scripting.FileSystemObject") 

if WScript.Arguments.Count = 0  Then
   WScript.Quit
End If

strfileFolder = objFSO.GetAbsolutePathName(WScript.Arguments(0)) 

'this line only works with cscript

WScript.StdOut.WriteLine "Times for file: " & strfileFolder

Set v = objFSO.GetFile(WScript.Arguments(0))
dm=v.DateLastModified
dc=v.DateCreated
da=v.DateLastAccessed
WScript.StdOut.WriteLine("Created:  "&dc)
WScript.StdOut.WriteLine("Modified: "&dm)
WScript.StdOut.WriteLine("Accessed: "&da)
barlop
  • 25,198