Howto delete an entire 'Tag-tree'?
Added by Picture Lover almost 10 years ago
Is it possible to delete an entire tree, like
Iptc.Application2.
including all the subtrees like
Iptc.Application2.RecordVersion
Iptc.Application2.ObjectName
Iptc.Application2.DateCreated
Iptc.Application2.TimeCreated
Iptc.Application2.Byline
Iptc.Application2.BylineTitle
Iptc.Application2.TransmissionReference
Iptc.Application2.Credit
Iptc.Application2.Source
Iptc.Application2.Copyright
Iptc.Application2.Caption
...
If I try
exiv2 -M"del Iptc.Application2" MyPicture.jpg
or
exiv2 -M"del Iptc.Application2." MyPicture.jpg
or
exiv2 -M"del Iptc.Application2.*" MyPicture.jpg
I get a
-M option 1: Invalid key `Iptc.Application2.*'
exiv2: Error parsing -M option arguments
Thanks for your help in advance!
Replies (4)
RE: Howto delete an entire 'Tag-tree'? - Added by Robin Mills almost 10 years ago
You may need to use a loop to do this.
On bash (on Mac/Linux/Cygwin), this is of the form:
for tag in a b c ; do exiv2 ..... $tag ... ; done
On windows cmd.exe, this is of the form:
for tag in (a,b,c) do exiv2 .... %tag ....
a b c are the actual values of interest:
Iptc.Application2.RecordVersion Iptc.Application2.ObjectName ...
If you want to do this often, it's probably useful to create a little .sh/.bat script. You can use exiv2 -pi to get all the IPTC commands in a file, and then use 'for' to run a loop deleting them one at a time. This is quite easy on bash and a little challenging on Windows. I've found this site http://www.dostips.com/ very useful for creating batch files on Windows.
Robin
RE: Howto delete an entire 'Tag-tree'? - Added by Steve Wright almost 10 years ago
Robin,
A little casual shell script poker to pique your interest.
"I'll see your for loop and raise you a while read line loop."
If you have a text file with a list of tags or labels you usually don't want to see Exiv2 -- or any other application supporting the display of metadata -- to read back from a file, you're not limited to just one kind of tag or label, and it saves time typing in the specific tags.
In a script, a 'while read line/do/done' loop to process a single file or multiple files, would do the same as your suggestion of a 'for/do/done' one.
This is something I would have to test for myself, but the concept is solid, don't you agree?
I'm not too partial, myself, to rudimentary "under-the-hood" tags like EXIF Version or IPTC Envelope stuff, or any of the long tags in binary or hex Photoshop is inclined to add among its XMP labels. My list would likely include things of this nature.
Steve W.
RE: Howto delete an entire 'Tag-tree'? - Added by Robin Mills almost 10 years ago
Steve
Larry Wall (he of Perl fame) always says TMTWTDI (which is pronounced Tim-Woody) and means "There's More Than one Way To Do It. For sure the concept of using while read do blaaa done to read a file of meta data keys is rock solid.
It might seem rather strange that I have to admit to not knowing much about meta data. The various features and relative merits of Exif/Xmp/IPTC meta data are a little lost on me. I must concede that you are much more knowledgable than I on how/why people use the myriad of keys provided.
So, thanks for the offer to play script poker, however I'm gonna sit this round out.
Robin
RE: Howto delete an entire 'Tag-tree'? - Added by Picture Lover almost 10 years ago
My approach is now:
1.) write/export all tags from the picture to a file
2.) delete all tags from the picture
3.) read/import only those tags I want/need