ExifTool Forum

ExifTool => Newbies => Topic started by: mülli on September 23, 2013, 02:47:42 PM

Title: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 23, 2013, 02:47:42 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 23, 2013, 03:50:37 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 23, 2013, 04:40:19 PM
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!
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 23, 2013, 04:58:53 PM
P.S.: Seems like I've found the similarity: All images that were edited with Gimp had no synchronized IPTC-data.

Best regards!
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 23, 2013, 05:02:42 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 24, 2013, 03:22:38 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 25, 2013, 07:12:52 AM
> 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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 25, 2013, 12:45:37 PM
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!
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 25, 2013, 01:27:36 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 25, 2013, 03:43:09 PM
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!
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 25, 2013, 05:10:52 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 29, 2013, 06:07:16 AM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 29, 2013, 07:42:50 AM
Hi Christoph,

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

- Phil
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 29, 2013, 08:50:23 AM
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!
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 29, 2013, 11:10:26 AM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on September 29, 2013, 02:04:50 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on September 29, 2013, 02:46:18 PM
Thank you very much for your help Phil!

Best regards,
Christoph
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on October 01, 2013, 01:36:03 PM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on October 01, 2013, 02:02:19 PM
Hi Christoph,

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

- Phil
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on October 08, 2013, 09:53:04 AM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: Phil Harvey on October 08, 2013, 11:38:52 AM
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
Title: Re: Copy IPTC data to XMP for directory ans all subdirectories
Post by: mülli on October 08, 2013, 01:49:18 PM
Thank you nevertheless!