Not all metadata properties extracted from a file are marked with tags. Some file formats and metadata standards allow fully custom properties that can’t be tagged by the library, because their purpose is not clearly defined in the corresponding specification. In such cases you can use the property name (or any other attribute) to locate and remove it. The following example demonstrates an advanced removal scenario.
Load a file to modify
Pass a search predicate to the remove_properties method
Check the number of properties that were actually removed
Save the changes
fromgroupdocs.metadataimportMetadatafromgroupdocs.metadata.taggingimportTagsdefremoving_metadata():withMetadata("input.docx")asmetadata:# Remove every property whose tags fall into the "content" categoryaffected=metadata.remove_properties(lambdap:any(tag.category==Tags.contentfortaginp.tags))print(f"Affected properties: {affected}")metadata.save("output.docx")if__name__=="__main__":removing_metadata()
input.docx is the sample file used in this example. Click here to download it.