Problems copying DateTimeOriginal to Keywords even though DateTimeOriginal is ok

Started by allobrogica, November 15, 2014, 12:59:30 AM

Previous topic - Next topic

allobrogica

Hello all,

I'm perplexed by a problem I'm having with exiftool and just a few images. I'm simply putting the Year the image was taken into the keywords field. Using the code below, it works nearly all the time just fine. However I have a few images where it doesn't.  Thanks for any guidance.

For the images that it doesn't seem read/write DateTimeOriginal properly:
-- when attempting to copy DateTimeOriginal to keyword, the result is blank otherwise it copies the year correctly.
-- the DateTimeOriginal field is NOT blank however when you list out the metadata on the file (original or post-processing)
-- the images were taken on same camera as those that work, howerver it's possible that I previously altered the Date metadata due to timezone. I can't remember if I altered via exiftool or Aperture. Either way, the DataTimeOriginal field is still intact and correct in the images that do not work when you look at the metadata via exiftool.

using: exiftool 9.39 osx 10.8.5

Script ("ekw" for reference below):
#!/bin/bash
for file in "$@"
do
exiftool '-keywords+<$IPTC:Sub-location, $IPTC:City, $IPTC:Province-state, r$XMP-xmp:Rating, $EXIF:DateTimeOriginal' -d %Y "$file"
exiftool -a -u -g1 "$file" | egrep 'Key|File Name'
done


I have tried changing the DateTimeOriginal field name slightly to other variations of DateTimeOriginal and result is the same. Again, this code works on 99% of my images so far (only using a month or so). I would like to stick with using DateTimeOriginal if possible (especially since I know it's there in the file's metadata).

Output on file that works correctly (99% of time):
$ ekw test-worksfine.jpg
    1 image files updated
File Name                       : test-working.jpg
Keywords                        : Art Soul Festival, Downtown Oakland, Oakland, California, r1, 2014


Output on file that does work correctly:
$ ekw test-datetimeoriginal-notworking.jpg
    1 image files updated
File Name                       : test-notworking.jpg
Keywords                        : Smitten Ice Cream, San Francisco, San Francisco, California, r2,


Exiftool metadata checks on same files:
$ exiftool -a -G test-working.jpg -v | grep Date
  FileModifyDate = 1416028949
  FileAccessDate = 1416028965
  FileInodeChangeDate = 1416028949
  | | ProfileDateTime = 1998 2 9 6 49 0
  | 8)  ModifyDate = 2014:08:02 15:12:09
  | | 5)  DateTimeOriginal = 2014:08:02 15:12:09
  | | 6)  CreateDate = 2014:08:02 15:12:09
  | DateCreated = 2014-08-02T15:12:09
  | CreateDate = 2014-08-02T15:12:09
  | ModifyDate = 2014-08-02T15:12:09


$ exiftool -a -G test-notworking.jpg -v | grep Date
  FileModifyDate = 1416028948
  FileAccessDate = 1416028965
  FileInodeChangeDate = 1416028948
  | | ProfileDateTime = 1998 2 9 6 49 0
  | 8)  ModifyDate = 2014:08:06 14:56:49
  | | 5)  DateTimeOriginal = 2014:08:06 14:56:49
  | | 6)  CreateDate = 2014:08:06 14:56:49
  | DateCreated = 2014-08-06T14:56:49
  | CreateDate = 2014-08-06T14:56:49
  | ModifyDate = 2014-08-06T14:56:49


StarGeek

I think the problem is that you're making one very long keyword, not individual keywords.  See FAQ 17.  Your command makes a single keyword consisting of all of "$IPTC:Sub-location, $IPTC:City, $IPTC:Province-state, r$XMP-xmp:Rating, $EXIF:DateTimeOriginal" and the keywords tag has a limit on how long it can be.   Try adding -Sep ', ' and  I think you'll get the tags you want.  To verify that it's working right, use the Sep option to change the separator.  For example, ExifTool -Sep '!!' -keywords test-working.jpg should output "Art Soul Festival!!Downtown Oakland!!Oakland!!California!!r1!!2014" if you have separate keywords instead of a single long one.

Also one other thing, you don't need to pipe through grep to get just certain tags.    If you want all the date tags, just use -*date*.  Want the keywords but don't want to type all that, just use -key*.
"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

allobrogica

Thanks! Adding -Sep ', ' did the trick. I didn't realize the mistake. Also thanks for the suggestions.

Phil Harvey

Ideally, it would be better to just write the keywords separately in the first place, like this:

exiftool '-keywords+<IPTC:Sub-location' '-keywords+<IPTC:City' '-keywords+<IPTC:Province-state' '-keywords+<r$XMP-xmp:Rating' '-keywords+<EXIF:DateTimeOriginal' -d %Y "$file"

but this would only produce different results in the case where one of your keywords contains ", ".

- 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 ($).