5

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?

2
  • @boboes if you thought this one was interesting, you should check out this one! superuser.com/questions/973547/…
    – barlop
    Commented Jun 27, 2016 at 9:13
  • on a different note, the question here may be relevant to the problem and answer here superuser.com/questions/588608/… in that perhaps in certain cases according to the answer there, robocopy might take seconds into account, in which case, this question that shows seconds, is particularly relevant.
    – barlop
    Commented Jun 27, 2016 at 9:14

2 Answers 2

14

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

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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .