Copy DateTimeOriginal to XMP:DateTimeDigitized

Started by nkdevgeek, February 22, 2023, 11:01:50 PM

Previous topic - Next topic

nkdevgeek

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

StarGeek

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 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, or XMP:DateCreated according to the IPTC Photo Metadata Standard.
"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

nkdevgeek

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

StarGeek

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

When you're using the 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"
"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

Phil Harvey

#4
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 and here.

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

StarGeek

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.
"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

Phil Harvey

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