Hi
For once, in these interestic times of IMatch Anywhere and so on, a trivial question.
And from the "good old Visual Basic".

I think, it is a trivial and easy question, but I come not on a solution.

I have a field ({File.MD.XMP::photoshop\TransmissionReference\TransmissionReference\0}).
This field has for, say, for 3 files a value, then for 4 another, for 2 another and so on.
This looks like here:
file1 Gordon
file2 Gordon
file3 Rosa Luxemburg
file4 Guess who
file5 Guess who
file6 Guess who
file7 Hard-cheese-Emmentaler
I want now numbering upwards these fields. For this I have a short script. This works fine, it appends numbers at the end, like
file1 Gordon-var-01
file2 Gordon-var-02
file3 Rosa Luxemburg-var-03
file4 Guess who-var-04
But I want this numbers not for all files, but for all files with the same value in the metadata-field.So after running the script, it should looks like this:
file1 Gordon-var-01
file2 Gordon-var-02
file3 Rosa Luxemburg-var-01
file4 Guess who-var-01
file5 Guess who-var-02
file6 Guess who-var-03
file7 Hard-cheese-Emmentaler-var-01
...means, for all files with the same value an upcounting number, for a new value it starts again with 0.
I think, it it easy, but maybe I am wrong, and it is not that easy.

Here is the script, what works fine, but counts simply all files, also, if the value of the metadata-field changes.
Option Explicit
Sub Main
Debug.Clear
Dim selection As Files
Set selection = Application.GetFileWindow(imfwtCurrent).SelectedFiles
If selection.Count = 0 Then
MsgBox "Please select at least one file."
Exit Sub
End If
Dim f As File
Dim vals As TagValues
Dim data As TagData
Dim kundenname As String
Dim nummer As Long
nummer = 1
For Each f In selection
Set data = f.TagData
Set vals = data("XMP::photoshop\TransmissionReference\TransmissionReference\0")
If vals.Count = 0 Then
MsgBox "Mindestens eine Datei hat keinen K-Dateiname-Eintrag!"
Exit Sub
End If
Dim oldval As String
oldval = vals(1)
vals.Set oldval & "-var-" & Format(nummer, "00")
nummer = nummer +1
data.Update vals
data.WriteBack
Next
End Sub
Does anybody of you has an idea or a solution?
Thanks in advance for any input.
BTW: I know, that WinWrap Basic will be not more part of IMatch in the near future 