ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: nkdevgeek on February 22, 2023, 11:01:50 PM

Title: Copy DateTimeOriginal to XMP:DateTimeDigitized
Post by: nkdevgeek on February 22, 2023, 11:01:50 PM
Hello,
For whatever reason, I have a directory full of images where exif:DateTimeOriginal does not match with the XMP:DateTimeDigitized.
How do I copy exif:DateTimeOriginal with appended timezone to XMP:DateTimeDigitized?

Can't seem to figure it out, so any help would be useful.

Thanks
-Neeraj
Title: Re: Copy DateTimeOriginal to XMP:DateTimeDigitized
Post by: StarGeek on February 22, 2023, 11:27:06 PM
Do you have the timezone already set in the correct OffsetTime* tag?  Or did you want to copy the time stamp and manually add the the time zone during the copy?

If the OffsetTimeOriginal is correctly set, then Composite:SubSecDateTimeOriginal (https://exiftool.org/TagNames/Composite.html) can be used to copy directly
exiftool "-XMP:DateTimeDigitized<SubSecDateTimeOriginal" /path/to/files/

To add it manually, you would use
exiftool "-XMP:DateTimeDigitized<${DateTimeOriginal}±00:00" /path/to/files/

One minor note, the XMP:DateTimeDigitized corresponds to the EXIF:CreateDate tag, which is called DateTimeDigitized by the EXIF spec.  The proper place in XMP to copy DateTimeOriginal is either XMP:DateTimeOriginal, according to the EXIF for XMP spec (https://web.archive.org/web/20180921145139if_/http://www.cipa.jp:80/std/documents/e/DC-010-2017_E.pdf), or XMP:DateCreated according to the IPTC Photo Metadata Standard (https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata).
Title: Re: Copy DateTimeOriginal to XMP:DateTimeDigitized
Post by: nkdevgeek on February 23, 2023, 09:53:41 PM
Hello,
Thank you for the quick response. The images had the timezone correctly set in correct OffsetTimeOriginal tag, so I am able to use the exiftool "-XMP:DateTimeDigitized<SubSecDateTimeOriginal" command to update the XMP:DateTimeDigitized.
What is the syntax for using CreateDate tag? I wasn't able to get this working:
exiftool "-XMP:DateTimeDigitized<${CreateDate}+05:30" .\test.jpg

Also I am never sure when to use curly brackets { and/or $ around tag names while writing. Can you provide some insights for the usage?

Thanks
-Neeraj
Title: Re: Copy DateTimeOriginal to XMP:DateTimeDigitized
Post by: StarGeek on February 24, 2023, 01:55:38 AM
Quote from: nkdevgeek on February 23, 2023, 09:53:41 PMWhat is the syntax for using CreateDate tag? I wasn't able to get this working:
exiftool "-XMP:DateTimeDigitized<${CreateDate}+05:30" .\test.jpg

It helps to copy/paste the command and output so we can see what the error actually is.  Was CreateDate actually set?  Are you on Mac/Linux/Powershell?  If so, then you need to use single quotes around anything with a dollar sign in it.

Windows CMD example:
C:\>exiftool -time:all -G1 -a -s y:\!temp\Test4.jpg
[System]        FileModifyDate                  : 2023:02:18 13:49:49-08:00
[System]        FileAccessDate                  : 2023:02:23 22:44:05-08:00
[System]        FileCreateDate                  : 1973:01:01 00:00:00-08:00
[ExifIFD]       CreateDate                      : 2023:02:23 12:00:00

C:\>exiftool -P -overwrite_original "-XMP:DateTimeDigitized<${CreateDate}+05:30" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -time:all -G1 -a -s y:\!temp\Test4.jpg
[System]        FileModifyDate                  : 2023:02:18 13:49:49-08:00
[System]        FileAccessDate                  : 2023:02:23 22:44:30-08:00
[System]        FileCreateDate                  : 1973:01:01 00:00:00-08:00
[ExifIFD]       CreateDate                      : 2023:02:23 12:00:00
[XMP-exif]      DateTimeDigitized               : 2023:02:23 12:00:00+05:30



QuoteAlso I am never sure when to use curly brackets { and/or $ around tag names while writing. Can you provide some insights for the usage?

When copying directly from one tag to another without adding or changing anything, then you don't need the dollar sign.  See Common Mistake #5b (https://exiftool.org/mistakes.html#M5)

When you're using the Advanced formatting feature (https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature), then you have to use the brackets and put the Perl code has to be inside them.

Otherwise, if you're adding extra text to a tag while copying, you only need to use brackets when the TAG name is directly followed with character that might be part of a tag name.  Basically, when any letter, number, or underscore (and hyphen maybe? Probably some others) directly follows the tag name, then the brackets are needed.  If there is a space following, then it isn't needed.

"-Description<${Description}Bracket Needed"
"-Description<${Description} Bracket Not Needed"
Title: Re: Copy DateTimeOriginal to XMP:DateTimeDigitized
Post by: Phil Harvey on February 24, 2023, 08:25:06 AM
Quote from: StarGeek on February 24, 2023, 01:55:38 AMif you're adding extra text to a tag while copying, you only need to use brackets when the TAG name is directly followed with character that might be part of a tag name.  Basically, when any letter, number, or underscore (and hyphen maybe? Probably some others) directly follows the tag name, then the brackets are needed.

The valid characters are A-Z, a-z, 0-9, - and _.  I've added this to the documentation here (https://exiftool.org/#tagnames) and here (https://exiftool.org/TagNames/).

But, the tag may be prefixed by a group name followed by a colon, and suffixed by "#", so I guess : and # would also be a problem, so I'll also update the -p option description in the application documentation to say this:

        Braces {} may be used around the tag name to separate
        it from subsequent text (and must be used if subsequent text begins with an
        alphanumeric character, hyphen, underline, colon or number sign).

(while not technically true, it gets the point across.  In fact, a colon is OK unless it is followed by an alphanumeric character or underline.)

- Phil
Title: Re: Copy DateTimeOriginal to XMP:DateTimeDigitized
Post by: StarGeek on February 24, 2023, 10:17:17 AM
I never really looked into this too deeply, but as a general rule, I've always just used braces anytime the following character wasn't a space.
Title: Re: Copy DateTimeOriginal to XMP:DateTimeDigitized
Post by: Phil Harvey on February 24, 2023, 02:52:36 PM
Quote from: StarGeek on February 24, 2023, 10:17:17 AMas a general rule, I've always just used braces anytime the following character wasn't a space.

Me too actually.  It's safest, and easiest to read.

- Phil