Skip to content

diegoeis/obsidian-conditional-properties

Repository files navigation

Conditional Properties (Obsidian Plugin)

Automate frontmatter property updates in your Obsidian notes using simple conditional rules. Define rules like: IF property X equals Y THEN set property Z to W. Run on the whole vault or only on the current file, manually or on a schedule.

What inspired me to do this plugin was: My Granola meeting notes imports weren’t bringing the same name values as my people notes. So, I created this plugin to correct the names of people in my notes.

https://i.imgur.com/xfz21us.png

Features

  • Define multiple rules with a simple IF/THEN model
  • Property Existence Check: Check if a property exists or not in the frontmatter
  • Operators: exactly, contains, notContains, exists, notExists, isEmpty
  • Multiple THEN actions per rule: Set multiple properties in a single rule
  • Comma-separated values: Set multiple values for a property (e.g., "work, apple" → properly formatted YAML array)
  • ADD/REMOVE actions: Choose to ADD values to a property or REMOVE specific values
  • Smart property merging: Add values to existing properties without duplicating
  • Scan Scope Options: Choose between entire vault, latest created notes, or latest modified notes
  • Configurable scan count: Set number of notes to scan (1-1000, default 15) for latest notes options
  • Title-based conditions: Use the note's title (first H1 after YAML frontmatter or inline title) as the IF condition
  • Run on the entire vault (settings button or command)
  • Run on the current file (command palette)
  • Scheduled scans with a minimum interval of 5 minutes
  • Safe updates: only frontmatter properties are modified, body content is preserved
  • Handles multi-value properties (arrays/strings): preserves existing values when adding

Settings

  • Scan interval (minutes): default 5, minimum 5
  • Scan Scope: Choose between "Latest Created notes", "Latest Modified notes", or "Entire vault"
  • Number of notes: When using latest notes options, set the number of notes to scan (1-1000, default 15)
  • Rules editor: add/remove rules, pick operator, edit values
  • Run now button (executes based on selected scope)
  • Add many values in the same THEN action separated by commas
  • Add multiple THEN actions

Installation (Development)

  1. Copy this folder into your vault at .obsidian/plugins/obsidian-conditional-properties.
  2. In Obsidian, go to Settings → Community Plugins → toggle this plugin.

This repository ships the compiled main.js. No build step is required for testing.

Operators

Property Operators

  • exactly: Checks if the property value exactly matches the specified value
  • contains: Checks if the property value contains the specified text
  • notContains: Checks if the property value does not contain the specified text
  • exists: Checks if the property exists in the frontmatter (ignores the value field)
  • notExists: Checks if the property does not exist in the frontmatter (ignores the value field)
  • isEmpty: Checks if the property exists but is empty (empty string or empty array) (ignores the value field)

Example: Using exists/notExists/isEmpty

# Rule: If 'status' property exists
IF: status exists
THEN: set priority to 'high'

# Rule: If 'reviewed' property does not exist
IF: reviewed notExists
THEN: set needs_review to true

# Rule: If 'tags' property exists but is empty
IF: tags isEmpty
THEN: add tags 'untagged'

# Note: isEmpty vs notExists
# - isEmpty: property exists in frontmatter but has no value (e.g., tags: "" or tags: [])
# - notExists: property is not present in frontmatter at all

Usage

Run now

  • Settings → Conditional Properties → "Run now" button (executes based on selected scan scope).
  • Command palette: "Run conditional rules on vault".

Run on current file

  • Command palette: "Run conditional rules on current file".

Scheduled execution

  • Settings → set "Scan interval (minutes)" (minimum 5). The plugin runs automatically using a timer.

Scan Scope Options

Choose which notes the plugin will scan when running rules:

  • Latest Created notes: Scan the most recently created notes (configurable count, default 15)
  • Latest Modified notes: Scan the most recently modified notes (configurable count, default 15)
  • Entire vault: Scan all notes in the vault

The scan scope can be configured in Settings → Conditional Properties → "Scan Scope".

Action Types

Property Actions

When setting properties in THEN actions, you can choose between different modes:

ADD (Default)

  • Adds the specified values to the property
  • Does NOT duplicate values if they already exist
  • Preserves existing values in the property
  • Preserves the IF condition value - will not remove it when adding new values

REMOVE

  • Removes the specified values from the property
  • Only removes values that exist
  • Preserves all other values in the property
  • Safe: does nothing if the value doesn't exist

OVERWRITE

  • Completely replaces the property value with the specified new value
  • Removes all existing values and sets only the new ones
  • Useful for resetting or fully updating a property
  • Warning: This will erase any existing data in the property

DELETE PROPERTY

  • Completely removes the property from the frontmatter
  • The property and all its values are deleted permanently
  • Warning: This action is irreversible and will permanently delete the property
  • No value field is required, as nothing is being set

How to use Property Actions

In the rules editor, each THEN action has a dropdown between the property name and value field:

  • Select ADD to add values (default behavior)
  • Select REMOVE to remove values
  • Select OVERWRITE to replace the entire property value
  • Select DELETE PROPERTY to remove the property entirely

Title Modification Actions

You can now modify note titles based on conditions. When adding a new action, select Change Title from the action type dropdown.

Features:

  • Add prefix: Add text at the beginning of the title
  • Add suffix: Add text at the end of the title
  • Date formatting: Use {date} for default date format or {date:FORMAT} for custom formats (e.g., {date:DD-MM-YYYY})

How to use:

  1. In the rules editor, click "+ Add action"
  2. Select "Change Title" from the action type dropdown
  3. Choose between "Add prefix" or "Add suffix"
  4. Enter the text to add (use {date} or {date:FORMAT} for dynamic dates)

Examples:

  • Add today's date as a prefix: {date} -
  • Add a custom formatted date as a suffix: - {date:DD/MM/YYYY}
  • Add a fixed prefix: [ARCHIVED]

Examples

Add tags without duplicating (exact match):

IF property: type, op: exactly, value: meeting
THEN set property: tags [ADD] work, important

Result: Adds "work" and "important" tags only if they don't already exist.

Remove old tags (exact match):

IF property: status, op: exactly, value: archived
THEN set property: tags [REMOVE] draft, wip

Result: Removes "draft" and "wip" tags if they exist.

Overwrite property value (exact match):

IF property: status, op: exactly, value: old
THEN set property: status [OVERWRITE] new

Result: Replaces the entire "status" property with "new", removing any previous values.

Delete a property (exact match):

IF property: tags, op: exactly, value: deprecated
THEN set property: old_tags [DELETE PROPERTY]

Result: Completely removes the "old_tags" property from the frontmatter.

Combine ADD and REMOVE (exact match):

IF property: tags, op: exactly, value: old-project
THEN set properties:
  - tags [REMOVE] old-project, legacy
  - tags [ADD] new-project, active
  - status [ADD] migrated

Result: Removes old tags, adds new ones, and sets status.

Substring containment:

IF property: name, op: contains, value: iago
THEN set property: tags [ADD] review

Result: Matches any value where the normalized text contains "iago" (e.g. "[[Diago Silva]]").

Rules

Each rule has:

  • ifProp: source property name (ignored for heading-based rules)
  • op: operator (exactly, contains, notContains)
  • ifValue: value to test (substring for contains/notContains)
  • thenActions: array of actions to execute, each with prop, value, and action (add/remove/overwrite/delete)

Examples

  1. Rename a person mention in a multi-value property
---
related_people: ["[[steve_works]]", "[[John Doe]]"]
---

Rule:

IF property: related_people, op: exactly, value: [[steve_works]]
THEN set property: related_people to [[Steve Jobs]]

Result:

---
related_people: ["[[Steve Jobs]]", "[[John Doe]]"]
---
  1. Set a status if a tag contains a keyword
IF property: tags, op: exactly, value: meeting
THEN set property: status to processed
  1. Ensure a property does not contain a value
IF property: source, op: notContains, value: transcript-auto
THEN set property: verified to true
  1. Set multiple properties when a condition is met (NEW!)
IF property: tags, op: exactly, value: meeting
THEN set properties:
  - status to processed
  - priority to high
  1. Update multiple related properties
IF property: project_status, op: exactly, value: completed
THEN set properties:
  - "status to done
  - "priority to low
  - "archived to true
  1. Set multiple tags at once
IF property: type, op: exactly, value: note
THEN set properties:
  - tags to work, apple, important
  1. Use heading-based condition
IF first level heading, op: contains, value: Meeting
THEN set properties:
  - tags to meeting, important

Note: The title is the first H1 heading after the YAML frontmatter, or the inline title if enabled. Rules are skipped for notes without a title.

Roadmap

  • Conditional IF/THEN rules engine
  • Property operators (exactly, contains, notContains, exists, notExists, isEmpty)
  • Multiple actions per rule
  • Export/import settings UI
  • Title prefix/suffix modifications with {date} placeholders
  • Scheduled scans and scoped run options
  • Run on current file
  • Verify if property is empty
  • Rename property
  • Execute changes in the note content, not only properties or titles
  • Advanced operators (regex, greater/less than)
  • Compound conditions (AND/OR/NOT)
  • Folder/tag scoping and new-note filters

Privacy

All processing happens locally in your vault. No data leaves your device.

License

MIT

About

Automate frontmatter property updates in your Obsidian notes using simple conditional rules.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •