Retaining existing keywords when copying all metadata from one picture to anothe

Started by bretorourke, January 10, 2023, 07:47:51 PM

Previous topic - Next topic

bretorourke

Hi, I found out how to copy all metadata from one picture to another (overwriting all data in the second picture) via the post at the bottom (thank you for that) but in addition to copying all metadata, I want to retain existing keywords that exist in the second picture. 

For instance, I store keywords in the "Authors" field so the scenario is this:

Picture 1 Authors field: winter; christmas; sam; emily
Picture 2 Authors field: sacramento

After running the Exiftool, the desired state for the second photo I want is then:

Picture 2 Authors field: winter; christmas; sam; emily; sacramento

Is there a setting I can use to retain keywords if they exist?

Thank you

https://exiftool.org/forum/index.php?topic=11021.0

Phil Harvey

Here is a little trick.  I don't have time right now to explain how this works in detail, but here goes:

exiftool -tagsfromfile SOME_SOURCE_FILE -all:all -subject-= SOME_TARGET_FILE

I would recommend copying -all:all as above if the source and target are the same format (eg. both .jpg).  This will copy the tags into the same location.

The -subject-= deletes existing empty subjects, and has the effect of preserving existing non-empty subject values in the target file.

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

bretorourke

Thank you so much for the reply.  I should have added that I need to run exiftool on a directory of 1000's of photos.  Per the link I sent above, my current settings for recursing photos in a directory is:

exiftool -tagsfromfile %d%-.20f.%e c:\users\user\videos\temp1

I tried adding -all:all and -subject-= above but it didn't work.

Is there a formatting issue I need to fix?

Again, thank you!

Phil Harvey

Just saying "it didn't work" doesn't help much.  What messages did ExifTool return?  What was your exact command?  Can you give an example of the source and target file names?

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

bretorourke

Hi, yes here are the details...

Example filenames are:
   Source: EV6200.jpg Target: EV6200-remini-enhanced
   Source: HawaiiTrip.jpg Target: HawaiiTrip-remini-enhanced

As mentioned, I have directories with contain either 100's or 1000's of photos that I'm processing.

Per your suggestions I tried adding "all" and "subject" in three different ways:

exiftool -tagsfromfile -all:all -subject-= %d%-.16f.%e C:\Users\User\videos\temp1
The error was: "File -all:all does not exist

exiftool -tagsfromfile %d%-.16f.%e -all:all -subject-= C:\Users\User\videos\temp1
The error was "Error opening file - C:\Users\User\videos\temp1... File not found"

exiftool -tagsfromfile %d%-.16f.%e C:\Users\User\videos\temp1 -all:all -subject-=
The error was "Error opening file - C:\Users\User\videos\temp1... File not found"

Note that without the "all" and "subject" parameters added EXIFTOOL runs great copying all metadata between files... but overwriting target files that have keywords in the AUTHOR field.

Thanks, Bret

Phil Harvey

Hi Bret,

Your 2nd and 3rd commands should work if you enter the proper source directory name.  Apparently C:\Users\User\videos\temp1 doesn't exist.  Try dragging and dropping the source folder onto the cmd window instead of typing the name to avoid typing errors.

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

bretorourke

Thank you... indeed I did have a typo in the URL.  However, trying both the 2nd and 3rd commands above didn't work... I had a test keyword in the AUTHOR field for two target files and both test keywords were overwritten by the source file.  Any other ways to achieve my goal?  Thank you for all your time!

Phil Harvey

This only works for list-type tags (like Subject).  Author can only hold one value.

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

bretorourke

From your Irfan Help (v4.62), the two fields that I am using that can indeed store multiple list-type tags, or in other words "multiple comma or semi-colon keywords" is $40093 and $E40094 - "XP Author" and "XP Keywords" respectively. 

Both fields appear to allow more than one value.

In Windows Explorer, "XP Author" shows up as the "Authors" field - with the ability to add multiple individual tags - the same is true for the "XP Keywords" field, which shows up in Explorer as "Tags".


bretorourke

One additional data point, at least in Windows, the "Subject" tag is a single value... it does not allow for multiple, list-type values.

I must be missing something.  Thank you for your time Phil!

bretorourke

Oh my apologies, I was referring to the Help in the IrfanView tool not EXIFTOOL.  I *think the IPTC and EXIF field definitions are likely the same for both tools.  My points above are still valid.  Thanks

Phil Harvey

The XP tags are not list type in ExifTool (see the EXIF Tags documentation -- list-type tags are indicated by a "+" in the Writable column).

XMP:Subject is definitely a list tag, is is what I would recommend using instead of XPKeywords.  Also, I would recommend XMP:Creator instead of XPAuthor.  The XP tags aren't as well supported as the XMP.  Both of these XMP tags are list type.

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

bretorourke

Thank you Phil for all the help.  It turns out that Windows is doing a poor job aligning with the standards.  My workflows currently rely on Windows 11 Explorer to easily add/change metadata and Explorer only shows it calls:

Tags (multi-value)
Authors (multi-value)
Comments (single value)
Camera Marker (single value)
Camera Model (single value)
(amongst other date/misc fields)

These fields appear to not align with EXIF standards (different names and different format - eg single vs multi-value).  Not even sure which Explorer fields map to which EXIF fields.

I would need to use some other tool besides Explorer that allows me to see dozens of photos visually then select multiple photos and make changes to multi-value fields (adding/changing/removing tags from all fields).  I'll hunt for a tool.

Thanks again.  I love your EXIFTool!  It's literally saving me weeks of time for every large batch of photos I'm processing.


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