remove_properties method

remove_properties

Removes metadata properties satisfying the specified predicate.

def remove_properties(self, predicate):
    ...
Parameter Type Description
predicate Func[MetadataProperty, bool] A function that receives a metadata property and returns True if the property should be removed.

Returns: int: The number of properties that were removed.

Example

from groupdocs.metadata import Metadata

with Metadata("input.docx") as metadata:
    affected = metadata.remove_properties(
        lambda p: p.name is not None and (
            "Revision" in p.name or
            "TrackedChange" in p.name or
            "LastPrinted" in p.name
        )
    )
    print(f"Properties removed: {affected}")
    metadata.save("output.docx")

See Also