### YAML Rule Examples for Obsidian Conditional Properties Source: https://github.com/diegoeis/obsidian-conditional-properties/blob/main/README.md Demonstrates various ways to configure rules using YAML syntax for the Obsidian Conditional Properties plugin. These examples cover auto-tagging, archiving, date-stamping, title standardization, and property deletion. ```yaml IF property: type = "meeting" THEN ADD tags: work, important ``` ```yaml IF property: status = "archived" THEN REMOVE tags: active, wip ``` ```yaml IF property: status = "done" THEN Change Title: Add suffix " - {date:DD/MM/YYYY}" ``` ```yaml IF title contains: "Meeting" THEN Change Title: Overwrite to "{date:YYYY-MM-DD} - {filename}" ``` ```yaml IF property: tags = "old-project" THEN DELETE PROPERTY: legacy_data ``` ```yaml IF title contains: "Meeting" THEN ADD tags: meeting, important ``` ```yaml IF property: project_status = "completed" THEN: - SET status [OVERWRITE]: done - ADD tags: archived - REMOVE tags: active, wip - ADD priority: low ``` -------------------------------- ### Obsidian Conditional Properties - Operators Reference Source: https://github.com/diegoeis/obsidian-conditional-properties/blob/main/README.md Provides a reference for the operators available in the Obsidian Conditional Properties plugin for defining conditions. Includes descriptions and examples for each operator. ```markdown | Operator | Description | Example | |-------------|-------------------|-----------------------| | `exactly` | Exact match | `type = "meeting"` | | `contains` | Substring match | `name contains "Diego"` | | `notContains`| Does not contain | `tags notContains "draft"` | | `exists` | Property present | `status exists` | | `notExists` | Property absent | `reviewed notExists` | | `isEmpty` | Empty value | `tags isEmpty` | ``` -------------------------------- ### Obsidian Conditional Properties - Title Placeholders Source: https://github.com/diegoeis/obsidian-conditional-properties/blob/main/README.md Illustrates the available placeholders for dynamic title manipulation within the Obsidian Conditional Properties plugin. Shows examples of date formatting and filename usage. ```markdown - `{date}`: File creation date (default format) Example: `{date}` → `2026-01-08` - `{date:FORMAT}`: Custom date format (moment.js) Example: `{date:DD-MM-YYYY}` → `08-01-2026` Example: `{date:YYYY/MM/DD}` → `2026/01/08` - `{filename}`: Current file basename (without .md) Example: For file `meeting-notes.md` → `meeting-notes` **Placeholder Combinations:** - `{date:YYYY-MM-DD} - {filename}` → `2026-01-08 - meeting-notes` - `Meeting {filename} - {date:DD/MM/YY}` → `Meeting meeting-notes - 08/01/26` - `{filename}` → `meeting-notes` (overwrite with just filename) ``` -------------------------------- ### Archive Old Projects with Multiple Actions (YAML/JSON) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt An example rule illustrating how to archive completed projects by updating their status, adding an 'archived' tag, removing 'active' and 'wip' tags, and setting a low priority. The rule is presented in both YAML and JSON formats. ```yaml # Rule: Archive completed projects IF property: project_status exactly "completed" THEN: - SET status [OVERWRITE]: done - ADD tags: archived - REMOVE tags: active, wip - ADD priority: low ``` ```json { "ifType": "PROPERTY", "ifProp": "project_status", "ifValue": "completed", "op": "exactly", "thenActions": [ { "type": "property", "prop": "status", "value": "done", "action": "overwrite" }, { "type": "property", "prop": "tags", "value": "archived", "action": "add" }, { "type": "property", "prop": "tags", "value": "active, wip", "action": "remove" }, { "type": "property", "prop": "priority", "value": "low", "action": "add" } ] } ``` -------------------------------- ### Auto-tag Obsidian Notes Based on Property Value (YAML/JSON) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt An example rule demonstrating how to automatically tag notes and set their priority based on a 'type' property. The rule is shown in both human-readable YAML format and its JSON representation used internally by the plugin. ```yaml # Rule: Tag all meeting notes IF property: type exactly "meeting" THEN: - ADD tags: work, important - SET priority [OVERWRITE]: high ``` ```json { "ifType": "PROPERTY", "ifProp": "type", "ifValue": "meeting", "op": "exactly", "thenActions": [ { "type": "property", "prop": "tags", "value": "work, important", "action": "add" }, { "type": "property", "prop": "priority", "value": "high", "action": "overwrite" } ] } ``` -------------------------------- ### Plugin Settings: Export and Import Configuration (JavaScript) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Backup and restore your plugin configuration by exporting settings to a JSON file and importing them back into the plugin. Imported settings merge with defaults and reload the UI. ```javascript // Export settings to JSON file // Downloads: conditional-properties-settings-2026-01-08.json async exportSettings() { const settings = JSON.stringify(this.plugin.settings, null, 2); // Creates downloadable JSON file } // Import settings from JSON file // Merges with defaults and reloads UI async importSettings(file) { const settings = JSON.parse(fileContent); this.plugin.settings = { ...defaultSettings, ...settings }; await this.plugin.saveData(this.plugin.settings); } ``` -------------------------------- ### Plugin Settings: Scan Scope and Interval (JavaScript) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Configure how and when the plugin scans your Obsidian vault. Settings include the scan interval, the scope of files to scan (entire vault, latest created, or latest modified), and the number of notes to process in scoped scans. ```javascript // Default settings structure const defaultSettings = { rules: [], // Array of rule objects scanIntervalMinutes: 5, // Minimum 5 minutes lastRun: null, // ISO timestamp of last scan scanScope: "latestCreated", // "latestCreated", "latestModified", or "entireVault" scanCount: 15 // Number of notes for scoped scans (1-1000) }; // Scan scope options: // - "latestCreated": Process newest notes (sorted by creation time) // - "latestModified": Process recently edited notes (sorted by modification time) // - "entireVault": Process all markdown files ``` -------------------------------- ### Check Property Existence and Empty Values (YAML) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Implement conditional logic based on whether a property exists, does not exist, or is empty. Actions include adding default values, deleting properties, or tagging notes. ```yaml # Rule: Add default status when missing IF property: status notExists THEN ADD status: draft # Rule: Clean up empty tags IF property: tags isEmpty THEN DELETE PROPERTY: tags # Rule: Flag notes with reviewed property IF property: reviewed exists THEN ADD tags: reviewed # Settings JSON for existence check: { "ifType": "PROPERTY", "ifProp": "status", "ifValue": "", "op": "notExists", "thenActions": [ { "type": "property", "prop": "status", "value": "draft", "action": "add" } ] } ``` -------------------------------- ### Modify Note Titles with Dynamic Placeholders (YAML) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Configure rules to dynamically modify note titles using date and filename placeholders. Supports custom date formats via moment.js. The 'Change Title' action can add a suffix or overwrite the existing title. ```yaml # Rule: Date-stamp completed tasks IF property: status exactly "done" THEN Change Title: Add suffix " - {date:DD/MM/YYYY}" # Result: "Task Name" → "Task Name - 08/01/2026" # Rule: Standardize meeting note titles IF title contains: "Meeting" THEN Change Title: Overwrite to "{date:YYYY-MM-DD} - {filename}" # Result: For file "team-sync.md" → "2026-01-08 - team-sync" # Available placeholders: # - {date}: File creation date (default format YYYY-MM-DD) # - {date:FORMAT}: Custom date format using moment.js (e.g., {date:DD-MM-YYYY}) # - {filename}: File basename without .md extension # Settings JSON for title modification: { "ifType": "PROPERTY", "ifProp": "status", "ifValue": "done", "op": "exactly", "thenActions": [ { "type": "title", "modificationType": "suffix", "text": " - {date:DD/MM/YYYY}" } ] } ``` -------------------------------- ### Condition Operator Matching Logic (JavaScript) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Implements the core logic for matching conditions based on various operators like 'exactly', 'contains', 'notContains', 'exists', 'notExists', and 'isEmpty'. It handles normalization and specific array-based matching rules. ```javascript // Operator matching logic _matchesCondition(source, expected, op, ifType) { switch (op) { case "exactly": // Exact match after normalization return normalizedSource === normalizedExpected; case "contains": // Substring match return normalizedSource.includes(normalizedExpected); case "notContains": // Does not contain substring return !normalizedSource.includes(normalizedExpected); case "exists": // Property is present (not undefined/null) return source !== undefined && source !== null; case "notExists": // Property is absent return source === undefined || source === null; case "isEmpty": // Property exists but is empty (empty string, empty array) return source.length === 0 || normalizedSource === ""; } } // Array handling: // - For "notContains": ALL array items must not contain the value // - For other operators: ANY array item matching is sufficient ``` -------------------------------- ### Conditional Logic Based on First Level Heading (YAML) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Apply rules based on the content of the first-level heading (H1) in a note. This allows for tagging or modifying titles based on the main topic of the note. ```yaml # Rule: Tag notes with "Meeting" in title IF title contains: "Meeting" THEN ADD tags: meeting, important # Rule: Create H1 when missing (using FIRST_LEVEL_HEADING) IF first level heading notExists THEN Change Title: Overwrite to "{filename}" # Settings JSON: { "ifType": "FIRST_LEVEL_HEADING", "ifProp": "", "ifValue": "Meeting", "op": "contains", "thenActions": [ { "type": "property", "prop": "tags", "value": "meeting, important", "action": "add" } ] } ``` -------------------------------- ### Run All Rules on Obsidian Vault (JavaScript) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Executes all defined conditional rules across the entire Obsidian vault. It scans files based on the 'scanScope' setting and applies rules, returning the count of scanned and modified files. This method is typically invoked by a command or a scheduled task. ```javascript async runScan() { const files = this._getFilesToScan(); // Based on scanScope setting let modifiedCount = 0; for (const file of files) { const cache = metadataCache.getFileCache(file) || {}; const frontmatter = cache.frontmatter ?? {}; const applied = await this.applyRulesToFrontmatter(file, frontmatter); if (applied) modifiedCount++; } return { scanned: files.length, modified: modifiedCount }; } // Trigger via Command Palette: "Run conditional rules on vault" // Result: Notice displays "Conditional Properties: 5 modified / 100 scanned" ``` -------------------------------- ### Run Rules on Single Obsidian File (JavaScript) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Applies all conditional rules to a specific file, useful for targeted automation or testing. It retrieves the file's frontmatter and processes it through the rule engine. The function returns a boolean indicating whether the file was modified. ```javascript async runScanOnFile(file) { const cache = this.app.metadataCache.getFileCache(file) || {}; const frontmatter = cache.frontmatter ?? {}; return await this.applyRulesToFrontmatter(file, frontmatter); } // Trigger via Command Palette: "Run conditional rules on current file" // Returns: true if file was modified, false otherwise ``` -------------------------------- ### Obsidian Conditional Rule Structure and Actions (JavaScript) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Defines the structure of a conditional rule, including conditions based on properties or first-level headings and a list of 'then' actions. It supports various operators for conditions and different action types for properties (add, remove, overwrite, delete, rename) and titles (prefix, suffix, overwrite). ```javascript // Rule structure example const rule = { ifType: "PROPERTY", // "PROPERTY" or "FIRST_LEVEL_HEADING" ifProp: "type", // Property name to check ifValue: "meeting", // Value to match against op: "exactly", // Operator: exactly, contains, notContains, exists, notExists, isEmpty thenActions: [ { type: "property", prop: "tags", value: "work, important", action: "add" }, { type: "property", prop: "status", value: "active", action: "overwrite" }, { type: "title", modificationType: "prefix", text: "[Meeting] " } ] }; // Action types for properties: // - "add": Add values without duplicating existing ones // - "remove": Remove specific values from property // - "overwrite": Replace entire property value // - "delete": Remove property completely // - "rename": Rename property to new name (preserves value) // Action types for titles: // - "prefix": Add text before title // - "suffix": Add text after title // - "overwrite": Replace entire title ``` -------------------------------- ### Rename Property Action (YAML) Source: https://context7.com/diegoeis/obsidian-conditional-properties/llms.txt Rename existing properties to new names while preserving their associated values. This is useful for migrating old property names to a new schema. ```yaml # Rule: Migrate old property names IF property: old_company exists THEN RENAME PROPERTY: old_company → company # Settings JSON: { "ifType": "PROPERTY", "ifProp": "old_company", "ifValue": "", "op": "exists", "thenActions": [ { "type": "property", "prop": "old_company", "action": "rename", "newPropName": "company" } ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.