Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R find time when a file was created

Tags:

file

r

metadata

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

like image 221
user2543622 Avatar asked Nov 21 '14 17:11

user2543622


People also ask

How to check creation time of file?

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.

How to check file creation date in Unix?

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.

How to know the date of a file in Linux?

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.

How to check the creation date of a directory in Linux?

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.


1 Answers

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" 
like image 108
Josh O'Brien Avatar answered Sep 21 '22 02:09

Josh O'Brien