You can manipulate metadata for specific notes using add and remove methods.
- Filter: Use
filter() to select a subset of notes based on existing metadata. The has_meta parameter accepts a list of tuples in the format (key, value, MetadataType). - Add: Use
metadata.add(k=key, l=value, meta_type=...) to insert new metadata. - Remove: Use
metadata.remove(k=key, l=value, meta_type=...) to delete specific metadata entries.
Always call update_content() and write() to persist these changes to the files.
# Filter notes that have a specific inline tag
notes.filter(has_meta=[("tags", "type/book", MetadataType.INLINE)])
# Add a new inline metadata field
notes.metadata.add(k="type", l="[[book]]", meta_type=MetadataType.INLINE)
# Remove an existing inline metadata field
notes.metadata.remove(k="tags", l="type/book", meta_type=MetadataType.INLINE)
# Apply changes and save
notes.update_content(inline_inplace=False, inline_position="top", inline_tml="callout") #type: ignore
notes.write()