Author Topic: Help assigning a value  (Read 1904 times)


  • Sr. Member
  • **
  • Posts: 354
Help assigning a value
« on: September 25, 2016, 05:25:25 AM »
Hello scripters,
I'm working on a small script to change annotations and need some help. I'm not a scripter, the little programming I did happened 30 years ago. I started of with modifying a script I "copied and pasted" together before. Using debug.print statements I think I got a routine which will do what I want to do. The one thing I can't figure out is how to assign a new tag value. The other script uses vals.Set (...), but that does not work with the tag I'm using.
The value I want to modify is "MWG::Regions\RegionsRegionListName\RegionName\0". I'm not exactly sure how that tag is structured, in the meta data browser I see all names separated with a semi column, but the region info tag which looks like xml data has the names as well, so the tag could be created from the region info tag. When the routine runs, I get each name in the routine "For Each v In vals" separately. I also know that I'm able to find the right name. I searched the help and tried to find information on the internet, but can't figure out how to set the new value. Neither vals.Set ("New Name") nor v = ("New Name") works. I admit that 'm not really sure what the difference between vals, v and data is.
I removed all the debug.print lines so it's easier to read the code.

Any help is greatly appreciated,


Code: [Select]
Sub UpdateData (ByRef selection As Files)
Dim f As File
Dim vals As TagValues
Dim v As TagValue
Dim data As TagData

For Each f In selection
' We *need* a local copy of the tag data
Set data = f.TagData
Set vals = data.Values ("MWG::Regions\RegionsRegionListName\RegionName\0")
If vals.Count > 0 Then ' First make sure there are values present to work with..
For Each v In vals ' And if there are values........
If Str$ (v) = "Name" Then

vals.Set ("New Name")
                                        v = ("New Name")

data.Update vals
End If
End Sub


  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31562
Re: Help assigning a value
« Reply #1 on: September 25, 2016, 08:06:35 AM »
XMP region tags are special, because they are structured complex tags. The region name is only a part of a complex structure, which also includes the coordinates and dimensions of the region and some other fields. I have never tried to update this from a script. Even IMatch updates always the entire region structure internally, in a special intermediate format that allows ExifTool to write the data via an XML construct.