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"
Getting the File Creation Date Using stat The easiest way to get the file creation date is with the stat command. As we can see, the creation date is shown in the “Birth” field.
1. To find a file creation date and time “crtime” is to find the inode of the file using the stat command against a file called “About-TecMint”. Alternatively, you can use the ls -i command against a file called “About-TecMint”. From the output of the above commands, the file inode number is 14420015.
The syntax is pretty simple; just run the stat command followed by the file's name whose last modification date you want to know, as shown in the example below.
The simplest way to get creation date for file & directory is using stat command. Here is an example where we create a file using echo & redirection operator, and use stat command to determine its creation date. The creation date for file is shown in Birth field.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With