add_properties method

add_properties

Adds known metadata properties satisfying the specified predicate, recursively affecting all nested packages.

Learn more

def add_properties(self, predicate, value):
    ...
Parameter Type Description
predicate Func[MetadataProperty, bool] A function to test each metadata property for a condition.
value PropertyValue A value for the picked properties.

Returns: int: The number of affected properties.

Example

from datetime import datetime

from groupdocs.metadata import Metadata
from groupdocs.metadata.common import PropertyValue
from groupdocs.metadata.tagging import Tags

def adding_metadata():
    with Metadata("input.docx") as metadata:
        property_value = PropertyValue(datetime.now())
        affected = metadata.add_properties(
            lambda p: Tags.time.printed in list(p.tags), property_value
        )
        print(f"Affected properties: {affected}")
        metadata.save("output.docx")

See Also