R find time when a file was created

I am using R function list.files to get a list of files in a folder. I would also like to record when each file was created, modified and accessed

how can i do that? i tried google search, but didnt find any useful command

Below screenshot is from my Windows machine. I get it when i right click a file name and click "properties"

enter image description here


Solution 1:

Check out file.info() for this and other file properties:

## With a single path
p <- R.home()
file.info(p)$ctime
# [1] "2014-11-20 08:15:53 PST"

## With a vector of multiple paths
paths <- dir(R.home(), full.names=TRUE)
tail(file.info(paths)$ctime)
# [1] "2014-11-20 09:00:45 PST" "2014-11-20 09:00:47 PST"
# [3] "2014-11-20 09:00:47 PST" "2014-11-20 09:00:50 PST"
# [5] "2014-11-20 09:00:33 PST" "2014-11-20 09:00:33 PST"