2
1
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
1
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?
8
You could use PowerShell to get that information.
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.
--------- //added by barlop
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>
-------------- // end added by barlop
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
//pic added by barlop
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)
What an interesting question - 3 years without upvotes. – marsh-wiggle – 2016-06-27T07:34:04.063
@boboes if you thought this one was interesting, you should check out this one! http://superuser.com/questions/973547/how-can-i-display-all-8-ntfs-timestamps
– barlop – 2016-06-27T09:13:46.753on a different note, the question here may be relevant to the problem and answer here http://superuser.com/questions/588608/why-does-robocopy-say-this-file-is-older 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 – 2016-06-27T09:14:48.113