remove_properties method

remove_properties

Removes metadata properties satisfying the specified predicate.

Learn more:

def remove_properties(self, predicate):
    ...
Parameter Type Description
predicate Func[MetadataProperty, bool] A function to test each metadata property for a condition.

Returns: The number of affected properties.

Example

with Metadata(input_path) 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
            or "TotalEditingTime" in p.name
            or "EditTime" in p.name))
    metadata.save(output_path)
    print(f"Properties removed: {affected}")

See Also