Writing IPTC Caption

Started by Duzeper, May 30, 2025, 10:39:58 AM

Previous topic - Next topic

Duzeper

How do I write into the IPTC Caption field of all files within a specific folder, the name of the folder?
So, if I have multiple files in, say D:\Pics\Test, then I want to write 'Test' into the IPTC Caption field of all files in that folder.

One point. I have tried this with another App (XnView MP) which does the job OK, but for some reason, at the same time it combines all the IPTC & XMP keywords it finds in all the files. I don't want that. I just want to write the folder name to the Caption field without changing anything else.

StarGeek

You don't mention your OS, which will change the command slightly.

Under Windows CMD (don't use Powershell), your command would be
exiftool "-Caption-Abstract<${directory;s(.*/)()}" D:\Pics\Test

On Mac/Linux, change the double quotes into single quotes.

For this command, you must not be in the directory you want to copy into the Caption-Abstract. You must either be above it or use the full path to the directory because the name of the current directory will be a dot . and not "test"

Note that this does not change the XMP:Description tag. You would have to set that separately. The reason I mention this is that you mention that XnView combining IPTC and XMP keywords. Writing one and not the other will fragment your metadata, making the IPTC/XMP data out of sync with the other.
"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

Duzeper

Thanks. Sorry, (I always forget to mention OS - it is Windows)
Although that appears to to the job, It does throw up some warnings;
Firstly there are a few thus:

Warning: [minor] Error reading PreviewImage from file - D:/Pics/Test/DSC00123.JPG
and some thus:

Warning: Invalid CanonCameraSettings data - D:/Pics/Test/DSC00123.JPG
Firstly, I have had no issues viewing these files

Also, I can't see  any difference in the EXIf Camera data between files that appear in that list and those that don't, and neither warning appears to have any effect on the outcome.
It seems that the second warning may be specific to that camera (which I no longer have) as I, so far, only see it with photos taken with that camera

One thing however:
The command is leaving behind 'originals' as in DSC00123.JPG_original.
I don't need these as I am working on copies anyway, so is there a switch in the command that is generating these or is there a switch to turn the option off?

By the way, when I mentioned  that XnView is combining IPTC and XMP keywords, what happens is that the command I tried was picking up ALL keywords from ALL files in the folder and combining those into each file, which I do not want. I have, however, found another way to do it in XnView which doesn't do that, but it is very slow for multiple files, so I would be happier to use Exiftool, which is much faster.

StarGeek

Quote from: Duzeper on May 31, 2025, 06:22:30 AMFirstly there are a few thus:

Warning: [minor] Error reading PreviewImage from file - D:/Pics/Test/DSC00123.JPG
and some thus:

Warning: Invalid CanonCameraSettings data - D:/Pics/Test/DSC00123.JPG

These are both warnings that do not affect the image itself. The first is most likely caused by some program editing the image or data, and it did not properly deal the offsets for the PreviewImage.

The second is, as you guessed, specific to a Canon camera. They are called MakerNotes and are proprietary data that almost every camera embeds in the files they create. Odds are that the data has been corrupted in the same way as PreviewImage. The only thing lost would be the settings of the camera at the time the photo was taken.


QuoteThe command is leaving behind 'originals' as in DSC00123.JPG_original.
I don't need these as I am working on copies anyway, so is there a switch in the command that is generating these or is there a switch to turn the option off?

Add the -overwrite_original option.
"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

Duzeper

Many thanks. Just what I needed.