- Thread Author
-
- #1
To get the exact time stamp attribute of a file in the command prompt, I use:
Using WMIC is necessary because the dir command can only show minutes. However, wmic datafile only works on files, not folders. I paid attention to using both the quotation marks and the two backslashes rather than one after the drive letter and the colon.
Is there any way to achieve this on folders?
Code:
wmic datafile where name="D:\\test1.txt" get LastModified
Using WMIC is necessary because the dir command can only show minutes. However, wmic datafile only works on files, not folders. I paid attention to using both the quotation marks and the two backslashes rather than one after the drive letter and the colon.
Is there any way to achieve this on folders?
Solution
Thanks, Neemobeer! Conveniently, it also supports wildcard selection.PowerShell is going to be a lot easier and is the preferred method.
You can access any property in multiple ways. As an example if all you want is the lat modified time
Code:Get-Item -Path C:\folder\or\file\path (Get-Item -Path C:\folder\or\file\path).LastWriteTime
While I am not all that familiar with PowerShell, I have found a way that can display both file name and the last modified time and the other two time attributes as a table:
Code:
dir * | select name,LastWriteTime,CreationTime,LastAccessTime
Sample output:
Code:
Name LastWriteTime LastAccessTime CreationTime
---- -------------...
- Joined
- Jul 4, 2015
- Messages
- 8,998
PowerShell is going to be a lot easier and is the preferred method.
You can access any property in multiple ways. As an example if all you want is the lat modified time
You can access any property in multiple ways. As an example if all you want is the lat modified time
Code:
Get-Item -Path C:\folder\or\file\path
(Get-Item -Path C:\folder\or\file\path).LastWriteTime
- Thread Author
-
- #3
Thanks, Neemobeer! Conveniently, it also supports wildcard selection.PowerShell is going to be a lot easier and is the preferred method.
You can access any property in multiple ways. As an example if all you want is the lat modified time
Code:Get-Item -Path C:\folder\or\file\path (Get-Item -Path C:\folder\or\file\path).LastWriteTime
While I am not all that familiar with PowerShell, I have found a way that can display both file name and the last modified time and the other two time attributes as a table:
Code:
dir * | select name,LastWriteTime,CreationTime,LastAccessTime
Sample output:
Code:
Name LastWriteTime LastAccessTime CreationTime
---- ------------- -------------- ------------
example.202211182130.mhtml 18.11.2022 21:30:33 03.12.2022 11:39:06 18.11.2022 21:30:33
example.202211182138.mhtml 18.11.2022 21:38:18 03.12.2022 11:39:06 18.11.2022 21:38:18
example.202211182153.mhtml 18.11.2022 21:53:32 03.12.2022 11:39:06 18.11.2022 21:53:31
example.202211201304.mhtml 20.11.2022 13:04:38 03.12.2022 11:39:06 20.11.2022 13:04:38
example.202211201318.mhtml 20.11.2022 13:18:33 03.12.2022 11:39:06 20.11.2022 13:18:33