News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Copy IPTC data to XMP for directory ans all subdirectories

Started by mülli, September 23, 2013, 02:47:42 PM

Previous topic - Next topic

mülli

Hello,

I have some thousands of files in a chronological directory structure. Many of them have IPTC-Captions as image description, and I'd like to generate XMP out of the IPTC-data. I would be glad if someone could explain me the correct command line switches for ExifTool to search for files with IPTC-metadata in a specific directory with subdirectories, copy it to XMP and leave all other files without IPTC untouched.

Best regards and thank you for your time and attention,
Christoph

Phil Harvey

Hi Christoph,

This may do what you want:

exiftool "-XMP-dc:Description<IPTC:Caption-Abstract" -r DIR

where DIR is the name of the directory containing the images.

This command will leave an "_original" backup file for each file that it modifies.

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

mülli

Thank you very much Phil! That worked, but files which already had XMP-data - eg. from Gimp or the camera - were not synchronized. Is it possible to search for all files that have IPTC-Data and then synchronize it with XMP regardless if the files have already XMP-metadata or not? By the way: Great work! One last question: If the batch is run through - can I be sure all IPTC data ist copied?

Best regards!

mülli

P.S.: Seems like I've found the similarity: All images that were edited with Gimp had no synchronized IPTC-data.

Best regards!

Phil Harvey

That command will only modify files containing IPTC:Caption-Abstract, regardless of whether they contained XMP or not.

Quote from: mülli on September 23, 2013, 04:40:19 PM
can I be sure all IPTC data ist copied?

But all IPTC data isn't copied.  Only the Caption-Abstract.

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

mülli

Quote from: Phil Harvey on September 23, 2013, 05:02:42 PM

But all IPTC data isn't copied.  Only the Caption-Abstract.

- Phil

That's not what I meant, sorry for my bad english. I'll try to explain:
The command does what I want, but I discovered, that it doesn't work with all files (that have IPTC-Caption-Abtracts!). As far as I can say, It doesn't work on images that were edited with Gimp. Gimp writes XMP-metadata on saving. After that I wrote an IPTC-Caption the Gimp-edited with XnView. Here is a file where you can reproduce the behaviour:
http://s1.directupload.net/file/u/44197/ztnewukj_jpg.htm
If you use the command on the image, the IPTC-Caption is NOT copied to XMP. My question was if i can be shure the script works reliable on all of my images (I want to run it on about 5000 files). I want to make shure the IPTC-Captions are copied properly to XMP on all files that have one.

Best regards and thanks for your help,
Christoph

Phil Harvey

> exiftool -a "-XMP-dc:Description<IPTC:Caption-Abstract" ztnewukj.jpg
Warning: Bad EquipmentIFD directory - ztnewukj.jpg
Warning: MakerNotes pointer references previous MakerNotes directory - ztnewukj.jpg
Warning: MakerNotes pointer references previous MakerNotes directory - ztnewukj.jpg
Warning: MakerNotes pointer references previous MakerNotes directory - ztnewukj.jpg
Warning: Error rebuilding maker notes (may be corrupt) - ztnewukj.jpg
Warning: [minor] Duplicate XMP property: exif:ResolutionUnit - ztnewukj.jpg
    0 image files updated
    1 image files unchanged

> exiftool -m -a "-XMP-dc:Description<IPTC:Caption-Abstract" ztnewukj.jpg
Warning: Bad EquipmentIFD directory - ztnewukj.jpg
Warning: MakerNotes pointer references previous MakerNotes directory - ztnewukj.jpg
Warning: MakerNotes pointer references previous MakerNotes directory - ztnewukj.jpg
Warning: MakerNotes pointer references previous MakerNotes directory - ztnewukj.jpg
    1 image files updated
...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 ($).

mülli

Thank you very much - seems to work now! I have seen that XnView has the same problem: I cant't write to XMP-Metadata edited by Gimp. What does the error mean? Is it a problem of Gimp or XnView (which maybe uses your software for editing metadata)?

Best regards!

Phil Harvey

Glad that helped.  The error that stopped the writing is a duplicate XMP tag.  ExifTool will delete one of the duplicate values when this is rewritten, hence the minor error.

I don't think GIMP uses ExifTool.  It seems to be an add-on for XnView, but I don't know what it is used for.

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

mülli

Okay, thank you for the reply! Meanwhile I have tested some more directories, and the command window showed a lot of errors. Can I be sure that all IPTC-Descriptions are copied properly when minor errors are ignored? Is it possible to generate a text report, or do you think that's needless?

Best regards and thanks for such a great work! I know that image metadata is a science for itself an it's impressive what a mighty tool you wrote!

Phil Harvey

Quote from: mülli on September 25, 2013, 03:43:09 PM
Can I be sure that all IPTC-Descriptions are copied properly when minor errors are ignored?

No.  Some errors are not minor.

QuoteIs it possible to generate a text report, or do you think that's needless?

It might be a good idea to scan for the word "Error" in the console output.

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

mülli

Hello Phil,

I've made a test run on all of my images in a test folder. My problem is, that the command promt doesn't show all messages, just the last dozens. So it's not possible to search for the word error. Is it possible to generate a txt-file report where I can see if any images were not properly written? It's very important for me to be absolutely sure that all desriptions are written.

Best regards,
Christoph

Phil Harvey

Hi Christoph,

Sure, like this:  exiftool ... > out.txt

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

mülli

Thank you Phil!
I now used "exiftool -m -a "-XMP-dc:Description<IPTC:Caption-Abstract" -r d:\test > out.txt", which led to following output:
"165 directories scanned
1716 image files updated
3760 image files unchanged"
But I think I have seen some error messages during processing. Would > out.txt show if there are imgaes that haven't been updated because of errors or do I have to specify the command somehow? Are the
3760 unchanged files definately the ones without IPTC-Description or may there be files with errors that have been ignored?

Best regards and thank you very much!

Phil Harvey

It looks like there weren't any errors because none were reported in the summary.  If there were errors, the summary should indicate the number, and your output txt file would have more details about which files had errors.  The files that weren't updated were ones that didn't contain IPTC:Caption-Abstract.

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

Phil Harvey

I was thinking about this again and realized I had things wrong.  The summary goes to stdout and the errors go to stderr.  On the Mac, this is what happens with errors:

> exiftool t1 -artist=me > t.out
Error: Writing of this type of file is not supported - t1

> cat t.out
    0 image files updated
    1 files weren't updated due to errors


I'm pretty sure this will be the same for Windows (but you would use the "type" command instead of "cat").

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

mülli

Thank you very much for your help Phil!

Best regards,
Christoph

mülli

Quote from: Phil Harvey on September 25, 2013, 01:27:36 PM
The error that stopped the writing is a duplicate XMP tag.  ExifTool will delete one of the duplicate values when this is rewritten, hence the minor error.
- Phil

Phil, allow me one last question: Is this a "false behaviour" of Gimp or is it just the specific way it deals with metadata like other programs which handle it all a different way? I ask this because if it's a "real" error I'd add it to the developer's error log.

Best regards,
Christoph

Phil Harvey

Hi Christoph,

I consider it a real error.  There shouldn't be any duplicate tags in the XMP.

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

mülli

Hello Phil,

you're right, it seems to be a bug of Gimp!
I've done some tests with other programs and contacted the developers of gimp as well as the developer of XnView.
http://newsgroup.xnview.com/viewtopic.php?f=36&t=28720
https://bugzilla.gnome.org/show_bug.cgi?id=709219
XnView uses the Adobe XMP Toolkit, which is not able to edit xmp data on images where gimp rewrote the xmp ans produced double fields. The same problem with iTag (http://www.itagsoftware.com/):
On all images I edited with gimp I get the message: "Exiv2-Library cant't read the image.
In the past years I edited a lot of images with Gimp, is there a way to find those with duplicate XMP and repair is? My images with IPTC-Desciptions are "automatically" repaired with the commandline you gave me, but it would be great if I could rewrite the XMP of all other images where gimp produced the error, too.

Thank you for your help and patience,
Christoph

Phil Harvey

Hi Christoph,

I can't think of any easy way to find all the affected files.  You could try writing them all then search for "Duplicate XMP property" in the ExifTool output, but this isn't a very elegant solution:

exiftool -xmp:title=x -o dummy/ -r DIR

Then delete the dummy output directory when you are done.

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