Hello,
I have got a problem to create a function with exiftool command in R. The idea is to enter a date in the function and the -SubSecDateTimeOriginal of the photo/folder was change by the date/time which was enter in the function. Moreover I would input a time step of 200ms.
So I wrote this small function :
recalage_photo <- function(date,hour) {
my_time <- paste(date,hour)
system("exiftool '-SubSecDateTimeOriginal=my_time' -d %Y:%m:%d %H:%M:%S.%f DIR -fileorder filename")
system("exiftool '-XMP:DateTimeOriginal<SubSecDateTimeOriginal' DIR -fileorder filename")
system("exiftool '-XMP:DateTimeOriginal+<0:0:${filesequence;$_*=0.200}' DIR -fileorder filename")
}
The problem is : "Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in Composite:SubSecDateTimeOriginal (PrintConvInv)
Nothing to do."
Even if date = 2021:01:14 and hour = 10:20:00.000 and my_time "2021:01:14 10:20:00.000".
So if you have any idea or advices.
Thank you in advance for your time.
Thomas
Hi Thomas,
This works on the command line:
> exiftool a.jpg -subsecdatetimeoriginal="2021:01:14 10:20:00.000" -v2
Writing Composite:SubSecDateTimeOriginal
Writing ExifIFD:DateTimeOriginal
Deleting ExifIFD:OffsetTimeOriginal
Writing ExifIFD:SubSecTimeOriginal
======== a.jpg
Rewriting a.jpg...
Editing tags in: APP0 APP1 Composite ExifIFD IFD0 JFIF
Creating tags in: APP1 Composite ExifIFD IFD0
JPEG APP1 (162 bytes):
Rewriting IFD0
Rewriting ExifIFD
+ ExifIFD:DateTimeOriginal = '2021:01:14 10:20:00'
+ ExifIFD:SubSecTimeOriginal = '000'
JPEG DQT (130 bytes):
JPEG SOF0:
JPEG DHT (73 bytes):
JPEG SOS
1 image files updated
I'm guessing that your "my_time" variable is not being expanded in the command line you are generating.
- Phil
Hi Mr. Harvey,
Thanks a lot for your answer and your help.
I find an other solution, so if someone are interesting :
recalage_photo <- function(date,hour,File1, DIR="DIR") {
my_time <- paste(date,hour)
command_exif <- paste0("exiftool -m '-SubSecDateTimeOriginal= ", my_time, "' ", DIR, " -fileorder filename -overwrite_original")
system(command_exif)
system(paste0("exiftool -m -SubSecDateTimeOriginal ", DIR, " -fileorder filename"))
system(paste0("exiftool -m '-XMP:DateTimeOriginal<SubSecDateTimeOriginal' ", DIR, " -fileorder filename -overwrite_original"))
system(paste0("exiftool -m '-XMP:DateTimeOriginal+<0:0:${filesequence;$_*=0.200}' ", DIR, " -fileorder filename -overwrite_original"))
system(paste0("exiftool -m -XMP:DateTimeOriginal ", DIR, " -fileorder filename"))
}
Have a nice day.
Thomas