I am using exiftool version 12.92 on WSL Linux.
I am building an argfile for use with exiftool using the command line syntax "-@ argfile" and am creating metadata in a pdf file.
The argfile contains exif commands like the following:
-XMP:Title=MyFile.pdf
-PDF:Title<XMP:Title
When I run exiftool using this argfile I get the warning:
Warning: No writable tags set from MyFile.pdf
The tag PDF:Title has not received a value in the metadata.
After trying different things, I believe there is a race condition.
The tag XMP:Title as not received a value when the copy from XMP to PDF
is done, and thus the copy fails.
Is there a way to pause execution and wait until the setting of the XMP
tag has completed?
Does this same behavior occur in TIFF and JPEG files when setting a tag
value in IPTC and copying it to an XMP or EXIF tag, and vice versa?
I worked around the problem by setting the value in both tags instead
of copying it as in:
-XMP:Title=MyFile.pdf
-PDF:Title=MyFile.pdf
I like the copy syntax better as it is more explicit as to the intent.
Thanks for your attention:
FAQ 22 (https://exiftool.org/faq.html#Q22) explains the order of operations. The last paragraph there is important: the source value for copied tags is always from the original file.
If you like the first syntax better, then you could do something like this:
-userparam
mytag=MyFile.pdf
-XMP:Title<mytag
-PDF:Title<mytag
- Phil
Quote from: pofeltag on March 06, 2025, 05:28:21 PMI believe there is a race condition.
The tag XMP:Title as not received a value when the copy from XMP to PDF
is done, and thus the copy fails.
It's not a race condition, it's how exiftool works. The tags are set only when the command is run. The previous tags remain cached so you can do things like swap tags or rebuild corrupt data (see FAQ #20 (https://exiftool.org/faq.html#Q20))
As an example, you can swap the value of tags without having to go through a third step or save the value to an external script variable
C:\>exiftool -G1 -a -s -xmp:all y:\!temp\Test4.jpg
[XMP-x] XMPToolkit : Image::ExifTool 13.22
[XMP-dc] Description : Description
[XMP-photoshop] Headline : Headline
C:\>exiftool -P -overwrite_original "-XMP:Description<XMP:Headline" "-XMP:Headline<XMP:Description" y:\!temp\Test4.jpg
1 image files updated
C:\>exiftool -G1 -a -s -xmp:all y:\!temp\Test4.jpg
[XMP-x] XMPToolkit : Image::ExifTool 13.22
[XMP-dc] Description : Headline
[XMP-photoshop] Headline : Description
QuoteIs there a way to pause execution and wait until the setting of the XMP
tag has completed?
The one other option than what Phil mentions is to run it as two separate commands using the
-execute option (https://exiftool.org/exiftool_pod.html#execute-NUM)
/path/to/file.pdf
-XMP:Title=MyFile.pdf
-execute
/path/to/file.pdf
-PDF:Title<XMP:Title
Note that any common arguments, such as the file name, either need to be duplicated each time in the args file, or added on the command line with the
-Common_Args option (https://exiftool.org/exiftool_pod.html#common_args). You do not add another
-execute to run the final group of commands.
But make no mistake, this is exactly like running the command twice. The file will be rewritten once to add a value to assign a value to
XMP:Title, and rewritten again to copy
XMP:Title into
PDF:Title.
Finally, the last option is to make a Shortcut user defined tag in your
.exiftool_config file. The Shortcut section is at the top of the
example.config file (https://exiftool.org/config.html). You would use this as your shortcut section
%Image::ExifTool::UserDefined::Shortcuts = (
MyTitle=> ['PDF:Title','XMP:Title'],
);
Now, when you write to
-MyTitle, e.g.
-MyTitle=MyFile.pdf, both of the
Title tags will be written at the same time.