In macOS, I’m trying to read old OpenMeta tags so I can rewrite them as new Finder tags. Here’s how I’m trying to read them:
[code]Public Sub FillList(theFolder as folderitem)
Dim theFile As FolderItem
Dim c, i As Integer
c = theFolder.Count
For i = 1 To c
theFile = theFolder.TrueItem (i)
If theFile <> Nil Then
Dim userTagsOM As Variant = ExtendedAttributesMBS.GetAttribute (theFile, “com.apple.metadata:kMDItemOMUserTags”)
// in debugger, userTagsOM shows as object(count)
with members names _variantString
Break // see in debugger
End If
Next[/code]
I don’t know how to parse the result of the getattribute function. The docs are unclear.
Please check TagNamesMBS and SetTagNamesMBS in folder item class.
I have and they work with today’s version of tags (which are _kMDItemUserTags
), but I’m trying to read the original OpenMeta attribute com.apple.metadata:kMDItemOMUserTags
that Apple used when tags were introduced.
In my above code GettAttribute
is returning an object array containing an item for each kMDItemOMUserTags
.
The question is how can I read the values of this object array? Is it a pair, or collection, or plain string array? I keep tripping over my feet trying to read it and am just looking to be pointed in the right direction.
com.apple.metadata:kMDItemOMUserTags is stored as binary plist.
For com.apple.metadata:_kMDItemUserTags you can use our ExtendedAttributesMBS functions to read directly:
[code]Dim f As FolderItem = SpecialFolder.Desktop.Child(“test.eml”)
// query attribute
Dim v As Variant = ExtendedAttributesMBS.GetAttribute(f, “com.apple.metadata:_kMDItemUserTags”)
// plugin converts it to XOjo data types with variants
If v <> Nil Then
// tags should be an array of Variant with strings
Dim a() As Variant = v
For Each s As String In a
MsgBox s
Next
End If[/code]
As far as I read you can use the same code for “com.apple.metadata:kMDItemOMUserTags”.
Thanks Christian. I ended up just using an array directly, like so:
Dim userTagsOM() As Variant = ExtendedAttributesMBS.GetAttribute (theFile, "com.apple.metadata:kMDItemOMUserTags")
This cleanly populates the variant array with the OpenMeta tags (and works with new tags as you mentioned).