ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: hvdwolf on December 14, 2012, 04:53:55 AM

Title: overwrite metadata export files
Post by: hvdwolf on December 14, 2012, 04:53:55 AM
Hi,
(Sorry if the answer is somewhere in this forum or in the application documentation but I simply couldn't find it.)

I've just added export metadata options to my pyExifToolGUI program, which as such is easy enough, but I'm running into an overwrite problem for the export files.
Say I want to export to xml using (in shell script now; shortest example):
for i in *.jpg; do exiftool -w xml -X -all "$i"; done
This works fine. However, when I do it a second time on the same images, exiftool doesn't want to overwrite the earlier created .xml files.
There are of course several work arounds by using something like:
for i in *.jpg; do exiftool -X -all "$i" > basename("$i").xml ; done
or
for i in *.jpg; do exiftool -X -all "$i" > $i.xml ; done
(I even prefer the second one in case you have for example image.cr2, image.tif and image.jpg and do a "for i in <All image types>", thereby creating image.cr2.xml, image.tif.xml and image.jpg.xml)

Question:  Is there some equal command/option like "-overwrite_original_in_place" for these export files (be it txt, tabbed txt, xml, csv, etc.)
Title: Re: overwrite metadata export files
Post by: Phil Harvey on December 14, 2012, 07:05:03 AM
The answer is in the -w option documentation:

            Existing files will not be overwritten unless an exclamation point
            is added to the option name (ie. -w! or -textOut!).

- Phil
Title: Re: overwrite metadata export files
Post by: hvdwolf on December 14, 2012, 08:01:26 AM
Thanks. Found it now.
Suggestion for the Option summary:
"-w[!] EXT   (-textOut)           Write output text files"
could perhaps be
"-w[!] EXT   (-textOut)           (Over)Write output text files"
or
"-w[!] EXT   (-textOut)           (Over[!])Write output text files"

That would make it more clear for users who don't search carefully enough  :-[
Title: Re: overwrite metadata export files
Post by: Phil Harvey on December 14, 2012, 08:37:08 AM
Thanks for the suggestion, but I think we need to be careful here or some people will think this command always overwrites the files.  This would be great:

  -w[!] EXT   (-textOut)           Write (-w) or overwrite (-w!) output text files

except the line is too long.

How about this?:

  -w[!] EXT   (-textOut)           Write (or overwrite!) output text files

- Phil
Title: Re: overwrite metadata export files
Post by: hvdwolf on December 14, 2012, 11:41:39 AM
Is
-w[!] EXT   (-textOut)           Write (-w) (overwrite -w!) output text files
too long (3 characters shorter) ?

If still too long, your second option is best.
Title: Re: overwrite metadata export files
Post by: Phil Harvey on December 14, 2012, 11:53:10 AM
Quote from: hvdwolf on December 14, 2012, 11:41:39 AM
Is
-w[!] EXT   (-textOut)           Write (-w) (overwrite -w!) output text files
too long (3 characters shorter) ?

Yup.  Still 3 characters too long.  So I'll go with my last suggestion.

Thanks.

- Phil