I have more than 800 pictures where I need to extract the date of creation. But if I use the file.mtime function, it's not working. It's just the date that I modified it. The funny thing is that iPhoto (a program on mac to manage photos) is able to detect the date of creation properly.
This is the code I was using.
my.path = "~/Desktop/cool_path_here"
vec.jpg = list.files(path = my.path)
lapply(paste(my.path,vec.jpg,sep = "/"),FUN = file.mtime)
Is there a function that could extract the date of creation of the photo and not the one that is shown in the "get info" menu on mac.
e.g.: (yesterday was May 18th)

and in iPhoto (found March 16th):

R is finding:
2017-05-19 15:08:29
Use the exif package to extract the metadata:
library(exif)
read_exif(paste(my.path,vec.jpg[1], sep="/"))$origin_timestamp
is returning "2017:03:16 08:47:48" which is the what I was looking for!
As per ?file.info, mtime is the modification time, ctime is the "last status change" time, and atime is the last "access" time. According to here, the POSIX standard (which Mac OS follows) does not include a creation time among the standard properties of a file.
file.info(my.path)$atime may be better. That didn't change in this test:
DF = data.frame(a = 1:10, b = 10:1)
tmp = tempfile()
write.table(DF, tmp)
Sys.time()
# [1] "2017-05-19 15:03:46 EDT"
file.info(tmp)[ , c('mtime', 'ctime', 'atime')]
# mtime ctime atime
# /tmp/Rtmpzpi8p6/file29e932565c62 2017-05-19 15:03:46 2017-05-19 15:03:46 2017-05-19 15:03:46
DF$c = 11:20
Sys.sleep(10)
write.table(DF, tmp)
file.info(tmp)[ , c('mtime', 'ctime', 'atime')]
# mtime ctime atime
# /tmp/Rtmpzpi8p6/file29e932565c62 2017-05-19 15:03:56 2017-05-19 15:03:56 2017-05-19 15:03:4
BTW, use the full.names argument to list.files instead of using paste and sep='/'.
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