Thread

Posted on Sat Aug 16 22:49:49 2008 by jgb60
Set ModifyDate to Current Date-Time
I just found and started using the Windows Executable version of ExifTool and can already see that it is very powerful but I have a lot to learn. I am trying automate some things with batch files but I would like to know how I can set ModifyDate to the current date/time in a Windows batch file? I can increment the current value and set it to a constant but I have not found a way to get the current date/time. Thanks, Drew
Direct Responses: 8594 | Write a response
Posted on Sun Aug 17 17:14:25 2008 by exiftool in response to 8591
Re: Set ModifyDate to Current Date-Time
Try this:

exiftool "-modifydate<$now" FILE

- Phil
Direct Responses: 8604 | Write a response
Posted on Mon Aug 18 02:04:12 2008 by jgb60 in response to 8594
Re: Set ModifyDate to Current Date-Time
That looks great but when I tried: exiftool "-ModifyDate=$now" img_2415.jpg . It replied:

Invalid date/time (use YYYY:MM:DD HH:MM:SS[.SS][+/-HH:MM|Z]) in IFD0:ModifyDate (PrintConvInv)

0 image files updated

1 image files unchanged

Did I do something wrong?
Direct Responses: 8605 | Write a response
Posted on Mon Aug 18 03:25:32 2008 by jgb60 in response to 8604
Re: Set ModifyDate to Current Date-Time
I apologize. I now see that it works if I do what you said. (use < instead of =) Thanks again.
Direct Responses: 8606 | Write a response
Posted on Mon Aug 18 08:56:23 2008 by fjord in response to 8605
Re: Set ModifyDate to Current Date-Time
Phil, I wonder if you could briefly explain why the $ references to tags works in the "<" assignment, but not in the "=" assignment. I am a new user that also spent many fruitless hours trying to get similar date tag updates to work, before I discovered that "=" and "<" behave very differently.
Direct Responses: 8607 | Write a response
Posted on Mon Aug 18 13:35:45 2008 by exiftool in response to 8606
Re: Set ModifyDate to Current Date-Time
It is simple:

"=" sets the value of a tag.

"<" copies the values of other tags.

Enhancements to the "<" syntax (see the -TagsFromFile section of the exiftool application documentation) allow a string containing tag names prefixed by "$", which is what we are doing here. Also, a special "now" tag is provided (see the Extra Tags documentation) to represent the current date/time.

- Phil
Direct Responses: 8608 | Write a response
Posted on Mon Aug 18 16:01:15 2008 by exiftool in response to 8607
Re: Set ModifyDate to Current Date-Time
One more note:

I just realized that you don't need the "$" syntax for this simple case. Just "-modifydate<now" will work just the same.

- Phil
Direct Responses: 8617 | Write a response
Posted on Mon Aug 18 21:49:50 2008 by fjord in response to 8608
Re: Set ModifyDate to Current Date-Time
Regarding "=" vs. "<", the difference, as I understand it, is what is permitted in the "expression" on the right side. In addition to copying a tag, the "<" form allows a kind of string expression using filename variables (%f etc.) and tag names ($tag), but the "=" form only allows constant values on the right. Is that correct?

Is -TAG<=FMT equivalent to -TAG<FMT? Or is "<=" only used in the form -TAG<=DATFILE to set a tag from the contents of a file?
Direct Responses: 8632 | Write a response
Posted on Tue Aug 19 21:48:26 2008 by exiftool in response to 8617
Re: Set ModifyDate to Current Date-Time
Close, but not quite. "=" takes a literal string as you mentioned. "<" takes a tag name. An extension to "<" also allows a string containing expressions like $TAG, which are expanded to the tag value. %f etc are only expanded when a filename is expected.

- Phil
Write a response