Search code examples
exiftool

EXIFTOOL: copy and concatenate QUICKTIME-, XML- and XMP-tags


I'm using EXIFTOOL-version 12.57 and I want to write metatags to MP4-files, but do not manage to copy and concatenate values from existing (group)tags and a text-string.

To create a [XMP]:Copyright-tag I want to copy the year of the [QUICKTIME]:CreateDate-Tag and add some copyright-text.

exiftool -d %Y -xmp:Copyright<quicktime:CreateDate target.MP4

stores the year (YYYY) of [QUICKTIME]:CreateDate to [XMP]:Copyright in the target.MP4-file. If [XMP]:Copyright does not exist it is created.

I want to add (existing) [XMP]:Author and some text to get a [XMP]:Copyright-tag like this:

®YYYY by [XMP]:Author. All rights reserved.

How do I concatenate [QUICKTIME]:CreateDate, [XMP]:Author and some text and write it to the [XMP]:Copyright-tag?

Have a nice day.


Solution

  • From the docs on the -TagsFromFile option

    An extension of the redirection feature allows strings involving tag names to be used on the right hand side of the < symbol with the syntax "'-DSTTAG<STR'", where tag names in STR are prefixed with a $ symbol. See the -p option and the "Advanced formatting feature" section for more details about this syntax.

    So the tag copy operation would be

    "-xmp:Copyright<©$quicktime:CreateDate by ${XMP:Author}. All rights reserved."
    

    Braces are used around XMP:Author due to the dot following directly behind the tag name. The details on needing the use of braces is detailed under the -p (-printFormat) option.

    There are a few things to take note of. You do not mention the OS and shell you're using. The above command is for Windows CMD. Under Mac/Linux, the dollar sign has special meaning inside of double quotes, so the double quotes need to be changed into single quotes. The same probably applies to Windows Powershell, but I'm not sure.

    Second, the example command in your question does not have quotes around the part of the command with the < symbol. Quotes are required otherwise the shell will interpret the < as file redirection and it will not get passed to exiftool.

    Additionally, there is an edge case where the year may be incorrect. Quicktime timestamps are supposed to be in UTC. A time zone difference around New Years Eve/Day might change the year. For example, a video shot at 2022:12:31 20:00:00-05:00 EST would be end up as 2023:01:01 01:00:00 (1 am UTC) in the file, resulting in a copyright of ©2023 instead of ©2022. The -api QuickTimeUTC option can be added to the command and exiftool will adjust the time to local time, giving the correct year.