Set explicit date for bulk files with different dates.

Started by abalter, March 03, 2015, 12:06:22 PM

Previous topic - Next topic

abalter

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.

Phil Harvey

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):

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).


abalter

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

StarGeek

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>
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

abalter

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?

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

abalter

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>






Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

abalter

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.

StarGeek

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

abalter

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?

StarGeek

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.



"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

abalter

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>

StarGeek

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype