I am seeking guidance about how to fetch the timestamp of a file from the file system. Searches within this forum or the Web have not proved fruitful for me and I came up with a solution a couple years ago but I think there must be a better way to do this. I am currently using 64-bit Stata IC 15.1 on Windows 10.

Use case example: in some cases, I'll check the timestamp of a CSV file, import the CSV only if it is newer than my DTA file, or skip the import step and use my existing DTA if the CSV is not newer.

For an example, I'll use a file found within BASE: arch.ado:
Code:
dir "C:\Program Files\Stata15\ado\base\a\arch.ado"
returns
58.2k 2/23/19 20:56 arch.ado

My current solution:
Code:
tempfile dirCmdResult
shell dir "`=subinstr("`c(sysdir_base)'", "/", "\", .)'a\arch.ado" > `dirCmdResult'
import delimited `dirCmdResult', clear delimiters(tab)
gen double timestamp = clock(v1, "MDY hm # #") // my Windows Regional Format is US mm/dd/yyyy hh:mm AP
quietly: summarize timestamp
local filesystemtimestamp `r(max)'

di %tc `filesystemtimestamp'
correctly returns
23feb2019 20:56:00

But I'm assuming there must be a far simpler way to do this. Any advice will be appreciated.

Thank you,
Marc Peterson