ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: damage on January 02, 2014, 06:08:34 AM

Title: Change DATE only in datetimeoriginal
Post by: damage on January 02, 2014, 06:08:34 AM
I would like to change a DATE part of datetimeoriginal and not the TIME. The DATE should come from a directory name. So far I came only to the solution, where I can reset time like this:

exiftool "-datetimeoriginal<${directory} 00:00:00" -r <path>

Is it possible to change DATE only and leave the TIME part intact?

The camera had the wrong date set, but not on all images in a subdirectories (there are hundreds of them). The directory names have all the correct date like "20130102 desc".
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on January 02, 2014, 10:26:13 AM
You could do it using the advanced formatting feature, like this:

exiftool "-datetimeoriginal<${directory} ${datetimeoriginal;s/.* //}" -r <path>

However, this will only work if the directory name doesn't contain any other numbers.  If it does, it would be necessary to do some formatting of the directory tag as well.

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: damage on January 02, 2014, 12:05:49 PM
Works like charm, thank you!
Title: Re: Change DATE only in datetimeoriginal
Post by: kzoppo on March 01, 2014, 05:42:46 AM
Maybe I am missing something but I get this when I try to do this

-bash: ${datetimeoriginal;s/.* //}': bad substitution

am I supposed to be changing any of this information? I am new and I can do what I want this way but what I really want to do is just change the date and leave the time without any directories involved. I've been searching but can't figure this out!

Thank you
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on March 01, 2014, 06:24:58 AM
On Mac/Linux you must use single quotes instead of double quotes around any argument containing a '$' symbol.

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: kzoppo on March 01, 2014, 07:30:39 AM
When I received the error I had input this

exiftool '-datetimeoriginal<${directory} ${datetimeoriginal;s/.* //}' -r <path>

Should I place more '?
Title: Re: Change DATE only in datetimeoriginal
Post by: Alan Clifford on March 01, 2014, 08:17:19 AM
Quote from: kzoppo on March 01, 2014, 07:30:39 AM
When I received the error I had input this

exiftool '-datetimeoriginal<${directory} ${datetimeoriginal;s/.* //}' -r <path>

Should I place more '?

'-datetimeoriginal - you've got a erroneous quote glyph there.
Title: Re: Change DATE only in datetimeoriginal
Post by: kzoppo on March 01, 2014, 11:47:47 AM
Ok, if I understand correctly you are telling me to input this

exiftool 'datetimeoriginal<${directory} ${datetimeoriginal;s/.* //}' -r <path>

But I still get the same error. Basically all I want to do is change the date of a photo but leave the time intact. I want to input the date, not refer it to a different location. I'm sure there is an easy solution but I don't know it.

Thanks
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on March 01, 2014, 01:44:24 PM
No, I think Alan was telling you to use ' instead of ' and '.  Command shells only respond to simple ASCII quotes:

exiftool '-datetimeoriginal<${directory} ${datetimeoriginal;s/.* //}' -r <path>

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: kzoppo on March 01, 2014, 03:25:59 PM
Ah ok I understand. Thank you. I input this

exiftool '-datetimeoriginal<${directory} ${datetimeoriginal;s/.* //}' -r

and it says that 1 file has been changed but when I look at all the dates

exiftool -time:all -a -G0:1 -s

They don't seem to have changed. I have also tried replacing directory with a date and I get

    0 image files updated
    1 image files unchanged
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on March 01, 2014, 07:11:54 PM
Add the -v2 option to see the details about what was changed.

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: kzoppo on March 02, 2014, 05:55:42 AM
Do you know how I can change the date on a file while leaving the time intact? I don't want the date to be referred to a different directory, I just want to input the date and leave the time unchanged.

Thanks
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on March 02, 2014, 07:28:05 AM
Then the command would look like this:

exiftool '-datetimeoriginal<2014:03:02 ${datetimeoriginal;s/.* //}' FILE

where FILE is the name of your file or directory.

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: kzoppo on March 03, 2014, 05:58:10 PM
Thank you that works great!
Title: Re: Change DATE only in datetimeoriginal
Post by: orbspider on May 05, 2014, 10:33:23 AM
Hi,

I want to something similar, but with -AllDates tag

I tried exiftool -m '-AllDates=2014:04:05 ${AllDates;s/.* //}' file

to no avail.  IMHO, the ${....} is complicated.  I would find exiftool easier to use if we could specify the date part or time with a tag, e.g.

exiftool -date -AllDates='2014:04:05' file
or
exiftool -time -AllDates='12:10:40' file

but maybe the tag has to follow, like
exiftool -AllDates='2014:04:05' -d file

I also tried
exiftool -date -AllDates='2014:04:05 0:0:0' file
as logically this should leave the time unchanged, but it returned "0 image files updated"

Am I missing something? cheers
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on May 05, 2014, 10:37:55 AM
What you want to do is equivalent to this:

exiftool -m '-DateTimeOriginal<2014:04:05 ${DateTimeOriginal;s/.* //}' '-CreateDate<2014:04:05 ${CreateDate;s/.* //}' '-ModifyDate<2014:04:05 ${ModifyDate;s/.* //}' FILE

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: orbspider on May 05, 2014, 10:59:09 AM
Ok, thanks Phil, so if that's the only way I'll use it, I just thought there might/could be an easier way of writing the command!
Title: Re: Change DATE only in datetimeoriginal
Post by: orbspider on May 05, 2014, 11:17:05 AM
Uh oh,
all the hr:min:sec time stamps got changed to the same- for 150 images (20:06:01.00) -might well be taken from the first image and written it to all of them??
that's not current time here.
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on May 05, 2014, 11:23:59 AM
More likely the times got messed up by an earlier incorrect command.  The command I gave should work.  (Note the quoting is for Mac/Linux)

> exiftool -alldates tmp
======== tmp/a.jpg
Date/Time Original              : 2003:10:31 15:44:19
Create Date                     : 2003:10:31 15:44:19
Modify Date                     : 2003:10:31 15:44:19
    1 directories scanned
    1 image files read

> exiftool -m '-DateTimeOriginal<2014:04:05 ${DateTimeOriginal;s/.* //}' '-CreateDate<2014:04:05 ${CreateDate;s/.* //}' '-ModifyDate<2014:04:05 ${ModifyDate;s/.* //}' tmp
    1 directories scanned
    1 image files updated

> exiftool -alldates tmp
======== tmp/a.jpg
Date/Time Original              : 2014:04:05 15:44:19
Create Date                     : 2014:04:05 15:44:19
Modify Date                     : 2014:04:05 15:44:19
    1 directories scanned
    1 image files read


You should be able to fix your problem with this command (assuming the "_original" files still exist):

exiftool -tagsfromfile %d%f.%e_original -m '-DateTimeOriginal<2014:04:05 ${DateTimeOriginal;s/.* //}' '-CreateDate<2014:04:05 ${CreateDate;s/.* //}' '-ModifyDate<2014:04:05 ${ModifyDate;s/.* //}' DIR

If you really want to set all of these date/time tags to a specific date while leaving the time the same, then I can't think of an easier way.

But if you just want to shift the date/time values by a constant amount, then you could use -alldates+="YEARS:MONTHS:DAYS 0" instead.

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: orbspider on May 05, 2014, 10:52:06 PM

dav>10:46:59:/media/FILES/my pictures/3$ exiftool -alldates test.jpg
Date/Time Original              : 2014:05:01 18:38:36
Create Date                     : 2014:05:01 18:38:36
Modify Date                     : 2014:05:01 18:38:36
dav>10:47:11:/media/FILES/my pictures/3$ exiftool -m '-DateTimeOriginal<2013:05:05 ${DateTimeOriginal;s/.* //}' '-CreateDate<2013:05:05 ${CreateDate;s/.* //}' '-ModifyDate<2013:05:05 ${ModifyDate;s/.* //}' *
Warning: Bad PreviewIFD directory - test.jpg
Warning: Deleted bad PreviewIFD directory - test.jpg
    1 image files updated
dav>10:47:41:/media/FILES/my pictures/3$ exiftool -alldates test.jpg
Date/Time Original              : 2013:05:05 20:14:05
Create Date                     : 2013:05:05 20:14:05
Modify Date                     : 2013:05:05 20:14:05



Obviously it's the old date Y:M:D going on as the new time, so anyhow, and with the shift method:

dav>10:59:03:/media/FILES/my pictures/3$ exiftool -alldates test2.jpg
Date/Time Original              : 2006:01:05 18:57:24
Create Date                     : 2006:01:05 18:57:24
Modify Date                     : 2006:01:05 18:57:24
dav>10:59:10:/media/FILES/my pictures/3$ exiftool -m -alldates+='8:2:1 0' test2.jpg
    1 image files updated
dav>10:59:38:/media/FILES/my pictures/3$ exiftool -alldates test2.jpg
Date/Time Original              : 2014:03:06 18:57:24
Create Date                     : 2014:03:06 18:57:24
Modify Date                     : 2014:03:06 18:57:24


much better results!
Title: Re: Change DATE only in datetimeoriginal
Post by: Phil Harvey on May 06, 2014, 07:28:47 AM
You must be using a very old version of ExifTool.  The advanced formatting feature was added in version 9.15 (over a year ago).  If you update your ExifTool, then the first technique will work.

- Phil
Title: Re: Change DATE only in datetimeoriginal
Post by: orbspider on May 06, 2014, 08:31:28 AM
indeed it is, v 8.60-2 from Debian stable repo.