A way to write XMP Subject from IPTC Keywords ?

Started by jgautier, January 31, 2018, 08:46:41 AM

Previous topic - Next topic

jgautier

Hi,

I need to rewrite XMP Subject of many images, and I'd like to write on this tag what is on IPTC keywords of each image.

For ex. for the moment one image has :
- XMP Subject = "AAAA,BBB"
- IPTC Keywords = "CCC,DDD"
After modification of this image, I want :
- XMP Subject = "CCC,DDD"
- IPTC Subject = "CCC,DDD"

And I need to do that for more than 300 000 images (with différent tags).

Is there a way that you suggest to do that ?

Thanks a lot for your help.

J. Gautier

Phil Harvey

To set XMP:Subject from the value of IPTC:Keywords, the command is:

exiftool "-XMP:Subject<IPTC:Keywords" DIR

I think this is what you want to do.

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

jgautier

Thanks a lot Phil.

One question :
Suppose this command stops (for a reason or another) before the end.
If I execute it again , will it start again from the beginning and write again all files ?

JG

Phil Harvey

Yes.  To avoid rewriting files unnecessarily, you could add this to the command:

-if "$IPTC:Keywords and (not $XMP:Subject or $XMP:Subject ne $IPTC:Keywords)"

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


jgautier

Sorry, but when I try the command It failed to recognize images that have different XMP:Subjet and IPTC:Keywords.

I put some images in a folder (called "hidef_test"), and type this command :
exiftool -if "$IPTC:Keywords and (not $XMP:Subject or $XMP:Subject ne $IPTC:Keywords)" "-XMP:Subject<IPTC:Keywords" hidef_test

But the command returns :
1 directories scanned
26 files failed condition
0 image files read

Can you understand why ?

JG

Phil Harvey

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

jgautier

Oh yes, you're right (I'm on linux) : sorry for my mistake.

JG