Effacer les filtres
Effacer les filtres

using dir() to get timestamp of file with ms precision

8 vues (au cours des 30 derniers jours)
supernoob
supernoob le 2 Oct 2018
Hi there,
I am looking to extract the timestamp (specifically, the "modification date") of some files in a folder. If I use dir(), then I can get the modification date in either datetime or datenum format. However, both of these give the timestamp to second precision, but I know the actual timestamp has millisecond precision. I want that millisecond precision. Is there any way to get the timestamp with millisecond precision using dir()? If not, how can I do this?
Thanks in advance!

Réponse acceptée

supernoob
supernoob le 4 Oct 2018
As Walter Roberson mentioned, this is impossible with dir(). One could use Jan's solution though that was not appropriate in this case. I ended up using shell.

Plus de réponses (1)

Jan
Jan le 2 Oct 2018
Under Windows you can use the C-Mex functions FEX: Filetime
  7 commentaires
Jan
Jan le 4 Oct 2018
Modifié(e) : Jan le 4 Oct 2018
@supernoob: The function GetFileTime can reply the time in the native format as stored in the file system as UINT64 counted in steps of 100ns. Then you can convert this how ever you like it.
The C-Mex function uses the Windows library function FileTimeToSystemTime, which rounds to milliseconds.
supernoob
supernoob le 4 Oct 2018
@Jan, thanks that's good to know. It seems likely the rounding error was from the FileTimeToSystemTime.

Connectez-vous pour commenter.

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by