I have a bunch of images with different create dates. I want to normalize them all to a given date (say today's date) using a batch file (Windows). Can ExifTool set dates? I only see documentation and examples for shifting dates. To shift the date to present, I would need to somehow read the date for each file, calculate the difference, and then shift. Can ExifTool let me read in the date to a variable in a batch file so I can do the math?
I tried:
exiftool -AllDates=2015:03/02 00:00:00 <image file>
Error: File not found - 00:00:00
0 image files updated
1 image files unchanged
1 files weren't updated due to errors
and a few variants.
The command syntax for what you were trying looks like this:
exiftool -AllDates="2015:03:02 00:00:00" <image file>
(you must put quotes around the date since it has a space in it, and use colons as separators)
But to set to the current date/time, there is a little trick (see FAQ 5 (https://exiftool.org/faq.html#Q5)):
exiftool -AllDates=now <image file>
note that <image file> may be more than one file and/or directory names to do multiple files at once.
- Phil
Awesome, thanks!
Oops. Spoke to soon. Got no error, and saw "1 image files updated" but date not actually changed. Actually, I can't get any dates to change at all even using shifting examples. What might I be doing wrong? Add attachemnt
Alldates is a shortcut for the DateTimeOriginal, CreateDate and ModifyDate tags. Those are what you're looking at through windows properties. The tags you want to use would be -FileCreateDate, -FileAccessDate, and -FileModifyDate. So your command would be something like
ExifTool -FileCreateDate="2014:01:01 00:00:00" -FileAccessDate="2014:01:01 00:00:00" -FileModifyDate="2014:01:01 00:00:00" <FILE/DIR>
Same problem. I've been playing around quite a bit. What happens is that the create date is unchanged, and the other dates simply become when the command was run. I've tried all sorts of dates and shifts. Identical behavior. There must be something wrong with the way I have things set up, but what?
StarGeek's example should work to set the filesystem date/times, except that FileAccessDate is not writable (it will be set to the same as FileModifyDate when you write that).
Can you post the output from these two commands?:
exiftool -FileCreateDate="2014:01:01 00:00:00" -FileModifyDate="2014:01:01 00:00:00" IMG_8220.JPG
exiftool -system:time:all IMG_8220.JPG
If the times displayed by the second command don't match the first, then there is something wrong. (Ignoring the FileAccessDate, which will change if any other software accesses the file.)
If the Windows properties for the file don't match those displayed by the second command (again, ignoring FileAccessDate), maybe try closing the properties window and opening it again.
- Phil
Ok, I think this is very interesting. I performed the test, and yes, the dates matched. They also match the properties box. So I tried a test again with AllDates, and this is what happened:
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -FileCreateDate="2014:01:01 00:00:00" -FileModifyDate="2014:01:01 00:00:00" IMG_8220.JPG
1 image files updated
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -system:time:all IMG_8220.JPG
File Modification Date/Time : 2014:01:01 00:00:00-08:00
File Access Date/Time : 2014:01:01 00:00:00-08:00
File Creation Date/Time : 2014:01:01 00:00:00-08:00
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -AllDates="2013:01:01 00:01:01" IMG_8220.JPG
1 image files updated
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -system:time:all IMG_8220.JPG
File Modification Date/Time : 2015:03:05 13:37:18-08:00
File Access Date/Time : 2015:03:05 13:37:17-08:00
File Creation Date/Time : 2014:01:01 00:00:00-08:00
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>
Yes. If you do -alldates alone, this is the expected result. Add -P to preserve the existing filesystem date/times, or assign them in the same command to whatever you want.
- Phil
It's not about preserving. For whatever reason, when I run AllDates, regardless of parameters, the date/times are set to the instant the command was run. Can you suggest a good test for me to use to demonstrate? Ok--I set the date/time as you suggested above, display it, set using just AllDates, then display it. At first, the create date is unchanged, but the modified date becomes current date -- not what is in the parameters to alldates.
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -FileCreateDate="2014:01:01 00:00:00" -FileModifyDate="2014:01:01 00:00:00" IMG_8220.JPG
1 image files updated
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -system:time:all IMG_8220.JPG
File Modification Date/Time : 2014:01:01 00:00:00-08:00
File Access Date/Time : 2014:01:01 00:00:00-08:00
File Creation Date/Time : 2014:01:01 00:00:00-08:00
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -AllDates="2014:01:01 00:00:00" IMG_8220.JPG
1 image files updated
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -system:time:all IMG_8220.JPG
File Modification Date/Time : 2015:03:05 20:03:55-08:00
File Access Date/Time : 2015:03:05 20:03:55-08:00
File Creation Date/Time : 2014:01:01 00:00:00-08:00
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -AllDates="2013:04:05 00:00:00" IMG_8220.JPG
1 image files updated
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -system:time:all IMG_8220.JPG
File Modification Date/Time : 2015:03:05 20:05:57-08:00
File Access Date/Time : 2015:03:05 20:05:57-08:00
File Creation Date/Time : 2014:01:01 00:00:00-08:00
The create date is not changing with AllDates, and the modification date is setting to the current date, regardless of the parameters to AllDates.
Quote
The create date is not changing with AllDates, and the modification date is setting to the current date, regardless of the parameters to AllDates.
As I mentioned previously, Alldates is a shortcut for the DateTimeOriginal, CreateDate, and ModifyDate tags. It will not affect any other tag. If you want to change the system file times, then you have to use FileModifyDate and FileCreateDate as previously mentioned.
Aha. I clearly need to read up on the difference between the DateTimeOriginal, CreateDate and FileCreateDate. I thought they were the same. Sounds like I might want to change all of them? Which are the ones seen in the file properties?
The ones seen in Properties are FileCreateDate and FileModifyDate (as well as FileAccessDate, but see Phil's comment about that above). These are date/times set by the OS, Windows in your case. Every file on the system will have these. Often backup programs will use FileModifyDate to tell if a file has changed and needs to be backed up.
DateTimeOriginal and CreateDate are date/time stamps inside of the file itself, usually set by the camera that took the picture. You won't find this info if you look at a .TXT file, for example. This info won't show up in the main properties window, but you can find it if you click the "Details" tab, if it exists. I believe (but could be wrong) that DateTimeOriginal will be under "Date Taken" in the Details tab.
Thanks for the explanation. So, suppose I want to change just the year, month and day of FileCreateDate, FileModifyDate, DateTimeOriginal, and CreateDate to the current day (but not time). Would this work?
exiftool -AllDates="2015:03:06 0" -FileModifyDate="2015:03:06 0" -FileCreateDate="2015:03:06 0" <file>
Unfortunately, no, it won't. Those tags need a full Date/Time. The zero there will set the time to 00:00:00. Your command is going to be a bit more complicated I think.
ExifTool "-alldates<${alldates;s/^\d{4}:\d\d:\d\d/2015:03:06/}" "-FileModifyDate<${FileModifyDate;s/^\d{4}:\d\d:\d\d/2015:03:06/}" "-FileCreateDate<${FileCreateDate;s/^\d{4}:\d\d:\d\d/2015:03:06/}" FILE/DIR
There may be a better way to do this, but if there is, I can't think of it at the moment.
Thanks for looking at it. Whew--I've never managed to learn regex's, so I would have never figured that out myself. Take a look at this output, and tell me if it makes sense. I'm noticing that the File Creation Date/Time still isn't changing. Do we need to add something?
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool alldates="2013:04:06 06:07:08" -FileModifyDate="2013:04:05 06:07:08" -FileCreateDate="2013:04:05 06:07:08" IMG_4334.JPG
Error: File not found - alldates=2013:04:06 06:07:08
1 image files updated
1 files weren't updated due to errors
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -system:time:all IMG_4334.JPG
File Modification Date/Time : 2013:04:05 06:07:08-07:00
File Access Date/Time : 2013:04:05 06:07:08-07:00
File Creation Date/Time : 2013:04:05 06:07:08-07:00
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>ExifTool "-alldates<${alldates;s/^\d{4}:\d\d:\d\d/2015:03:06/}" "-FileModifyDate<${FileModifyDate;s/^\d{4}:\d\d:\d\d/2015:03:06/}" "-FileCreateDate<${FileCreateDate;s/^\d{4}:\d\d:\d\
d/2015:03:06/}" IMG_4334.JPG
1 image files updated
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>exiftool -system:time:all IMG_4334.JPG
File Modification Date/Time : 2015:03:06 05:07:08-08:00
File Access Date/Time : 2015:03:06 05:07:08-08:00
File Creation Date/Time : 2013:04:05 06:07:08-07:00
Is there a way I can look at the Date Time Original and Create Date to confirm they are getting updated?
Thanks
I'm not sure why FileCreateDate isn't getting updated, it works here. Maybe try just that part. Make sure it's on one line,
You can look at the DateTimeOriginal and CreateDate by using ExifTool -DateTimeOriginal -CreateDate FILE or ExifTool -alldates FILE. The last one will show you ModifyDate as well.
Finally, the error from your first command is because there wasn't a dash - in front of AllDates
Seems like it's close to working. I don't understand the difference in behavior between the three date time modification results that are each using the same regex.
test.cmd:
@echo off
set dt=2010:09:08 07:06:05
echo %dt%
exiftool "-alldates=%dt%" IMG_4334.JPG
exiftool "-FileModifyDate=%dt%" IMG_4334.JPG
exiftool "-FileCreateDate=%dt%" IMG_4334.JPG
exiftool -system:time:all IMG_4334.JPG
exiftool -alldates IMG_4334.JPG
exiftool "-alldates<${FileModifyDate;s/^\d{4}:\d\d:\d\d/%dt%/}" IMG_4334.JPG
exiftool "-FileCreateDate<${FileCreateDate;s/^\d{4}:\d\d:\d\d/%dt%/}" IMG_4334.JPG
exiftool "-FileModifyDate<${FileModifyDate;s/^\d{4}:\d\d:\d\d/%dt%/}" IMG_4334.JPG
exiftool -system:time:all IMG_4334.JPG
exiftool -alldates IMG_4334.JPG
set dt=%1
echo %dt%
exiftool "-alldates<${FileModifyDate;s/^\d{4}:\d\d:\d\d/%dt%/}" IMG_4334.JPG
exiftool "-FileCreateDate<${FileCreateDate;s/^\d{4}:\d\d:\d\d/%dt%/}" IMG_4334.JPG
exiftool "-FileModifyDate<${FileModifyDate;s/^\d{4}:\d\d:\d\d/%dt%/}" IMG_4334.JPG
exiftool -system:time:all IMG_4334.JPG
exiftool -alldates IMG_4334.JPG
gives:
C:\Users\abalter\Documents\Image-ExifTool-9.88\testimages>test 2014:03:06
2010:09:08 07:06:05
1 image files updated
1 image files updated
1 image files updated
File Modification Date/Time : 2010:09:08 07:06:05-07:00
File Access Date/Time : 2010:09:08 07:06:05-07:00
File Creation Date/Time : 2010:09:08 07:06:05-07:00
Date/Time Original : 2010:09:08 07:06:05
Create Date : 2010:09:08 07:06:05
Modify Date : 2010:09:08 07:06:05
1 image files updated
1 image files updated
1 image files updated
File Modification Date/Time : 2010:09:08 08:06:05-07:00
File Access Date/Time : 2010:09:08 08:06:05-07:00
File Creation Date/Time : 2010:09:08 07:06:05-07:00
Date/Time Original : 2010:09:08 07:06:05
Create Date : 2010:09:08 07:06:05
Modify Date : 2010:09:08 07:06:05
2014:03:06
1 image files updated
1 image files updated
1 image files updated
File Modification Date/Time : 2014:03:06 15:39:11-08:00
File Access Date/Time : 2014:03:06 15:39:11-08:00
File Creation Date/Time : 2014:03:06 06:06:05-08:00
Date/Time Original : 2014:03:06 08:06:05
Create Date : 2014:03:06 08:06:05
Modify Date : 2014:03:06 08:06:05
file and image attached.
If you're questioning why the time changes, that's due to the nature of FileModifyDate. This is part of the underlying OS (Windows, in your case). Every time a file gets changed, the OS will update the FileModifyDate. So when you set that value, but follow up with another command to change something else without using the -P (http://www.exiftool.org/exiftool_pod.html#p) option, it's going to change.
I think I understand that. All the date/times are weird. For instance, in the final example (date entered as command line argument) The file modification date/time and file access date/time have the YEAR entered, but execution time.
File Modification Date/Time : 2014:03:06 15:39:11-08:00
File Access Date/Time : 2014:03:06 15:39:11-08:00
Also, in the 2nd example (using regex's with internally defined year/month/day), the File Modification Date/Time and File Access Date/Time are neither the original time (07:06:05) nor the time at execution.
Finally, in the 3rd example (year/month/day from command line argument), ALL the times except the first two (which are set by execution time) are wrong. They also should be 07:06:05.
I sure do appreciate the help. I hope this isn't too much work for you.