To make manipulating metadata easier, GroupDocs.Metadata attaches specific tags to the most commonly used metadata properties extracted from a file. Some metadata standards can have quite a complex structure. Moreover, in most cases one image, video or document contains more than one metadata package. Using tags you can search for the properties you want with a few lines of code without even knowing the exact format of the loaded file.
In Python you search by passing a predicate — any lambda (or function) that takes a single MetadataProperty and returns True/False — to the find_properties method. The groupdocs.metadata.tagging.Tags catalog gives you the tags to test against.
The code sample below demonstrates how to search for specific metadata properties using tags:
Load a file to examine
Build a predicate that checks a property carries a specific tag (or a combination of tags)
Pass the predicate to the find_properties method
Iterate through the found properties
fromgroupdocs.metadataimportMetadatafromgroupdocs.metadata.taggingimportTagsdeffind_metadata_properties():# Fetch all the properties satisfying the predicate:# the property carries the "last editor" tag OR the "modified date/time" tagwithMetadata("input.pptx")asmetadata:properties=metadata.find_properties(lambdap:Tags.person.editorinlist(p.tags)orTags.time.modifiedinlist(p.tags))forpropinproperties:print(f"Property name: {prop.name}, Property value: {prop.value}")if__name__=="__main__":find_metadata_properties()
input.pptx is the sample file used in this example. Click here to download it.
As a result, we obtain all metadata properties that hold the name of the person who last edited the document and all properties that store the date/time the document was last edited.
For more information on searching metadata, please refer to the following articles: