Examples
Real-world examples of YAML Toolkit for Obsidian rules using the universal FOR pattern.
Note: Examples show Condition → Action format. Enter these in separate fields in the plugin.
Content Management
Mark Drafts for Review
Input:
---
title: My Note
status: draft
tags: [project, active]
---Condition: status = "draft" AND HAS tags
Action (Rule 1): SET status "ready-for-review"
Action (Rule 2): SET reviewed_date "2025-11-24T21:45:00"
Output (after both rules):
---
title: My Note
status: ready-for-review
tags: [project, active]
reviewed_date: 2025-11-24T21:45:00
---Multiple Fields
To set multiple top-level fields, create two separate rules with the same condition.
Archive Old Notes
Input:
---
title: Old Project
created_date: 2023-06-15
tags: [notes, project]
---Condition: created_date < "2024-01-01" AND NOT tags contains "keep"
Action: FOR tags APPEND "archived"
Output:
---
title: Old Project
created_date: 2023-06-15
tags: [notes, project, archived]
---Tagging Operations
Add Tag to Untagged Notes
Input:
---
title: Untagged Note
status: active
---Condition: NOT HAS tags
Action: SET tags ["untagged"]
Output:
---
title: Untagged Note
status: active
tags: [untagged]
---Clean Up Multiple Deprecated Tags
Input:
---
title: Legacy Note
tags: [draft, wip, temp, project, active]
---Condition: HAS tags
Action: FOR tags REMOVE_ALL ["draft", "wip", "temp"]
Output:
---
title: Legacy Note
tags: [project, active]
---Metadata Management
Add Missing Status
Input:
---
title: New Note
---Condition: NOT HAS status
Action (Rule 1): SET status "draft"
Action (Rule 2): SET created_date "2025-11-24T22:10:00"
Output (after both rules):
---
title: New Note
status: draft
created_date: 2025-11-24T22:10:00
---Update Metadata
Input:
---
title: Settings
custom_field: old-value
---Condition: custom_field = "old-value"
Action (Rule 1): SET custom_field "new-value"
Action (Rule 2): SET updated_date "2025-11-24"
Output (after both rules):
---
title: Settings
custom_field: new-value
updated_date: 2025-11-24
---Priority Management
Flag High Priority
Input:
---
title: Critical Task
priority: 9
tags: [work, project]
---Condition: priority > 7 AND NOT tags contains "urgent"
Action: FOR tags APPEND "urgent"
Output:
---
title: Critical Task
priority: 9
tags: [work, project, urgent]
---Reset Priorities
Input:
---
title: Finished Task
status: completed
priority: 5
---Condition: status = "completed"
Action: DELETE priority
Output:
---
title: Finished Task
status: completed
---Date Operations
Mark Overdue
Input:
---
title: Late Task
deadline: 2025-11-01
status: active
---Condition: HAS deadline AND deadline < "" AND status != "completed"
Action: SET status "overdue"
Output:
---
title: Late Task
deadline: 2025-11-01
status: overdue
---String Operations
Strip Title Prefixes
Input:
---
title: Dr. John Smith
author: Dr. Jane Doe
---Condition: author contains "Dr."
Action: REPLACE author /^Dr\.?\s+// ""
Output:
---
title: Dr. John Smith
author: Jane Doe
---Mark Drafts with Prefix
Input:
---
title: Important Article
status: draft
---Condition: status = "draft" AND NOT title contains "DRAFT: "
Action: INSERT title "DRAFT: " AT 0
Output:
---
title: DRAFT: Important Article
status: draft
---Build Processing Log
Input:
---
title: Research Note
notes: "Initial draft completed"
---Condition: HAS notes
Action: INSERT notes "\n\n---\nReviewed: 2025-12-05" AT -1
Output:
---
title: Research Note
notes: "Initial draft completed\n\n---\nReviewed: 2025-12-05"
---Numeric Operations
Track View Count
Input:
---
title: Popular Article
views: 42
---Condition: HAS views
Action: INCREMENT views 1
Output:
---
title: Popular Article
views: 43
---Initialize Missing Counter
Input:
---
title: New Article
---Condition: NOT HAS views
Action: INCREMENT views 1
Output:
---
title: New Article
views: 1
---Complex Rules
Conditional Workflow
Input:
---
title: High Priority Item
status: active
priority: 8
tags: [project]
---Condition: (status = "active" OR status = "pending") AND priority >= 5 AND NOT tags contains "reviewed"
Action (Rule 1): SET status "in-review"
Action (Rule 2): SET review_date "2025-11-24T22:10:00"
Action (Rule 3): FOR tags ADD "reviewed"
Output (after all three rules):
---
title: High Priority Item
status: in-review
priority: 8
tags: [project, reviewed]
review_date: 2025-11-24T22:10:00
---Multiple Operations
This workflow requires three separate rules with the same condition.
Working with Arrays of Objects
These examples show operations for arrays of structured objects (tasks, meetings, reading lists), not simple scalar arrays (tags).
Update Specific Array Items
What makes this unique: Update fields within specific array items based on their properties.
Example: Task Management
Input:
---
title: Weekly Tasks
tasks:
- name: Review PR #123
status: pending
priority: 8
assignee: alice
- name: Update documentation
status: pending
priority: 3
assignee: bob
- name: Fix critical bug
status: done
priority: 9
assignee: alice
---Rule: Flag high-priority pending tasks as urgent
Condition: HAS tasks
Action: FOR tasks WHERE status = "pending" AND priority >= 7 SET status "urgent", flagged trueOutput:
---
title: Weekly Tasks
tasks:
- name: Review PR #123
status: urgent # ← Changed
priority: 8
assignee: alice
flagged: true # ← Added
- name: Update documentation
status: pending # ← Unchanged (priority too low)
priority: 3
assignee: bob
- name: Fix critical bug
status: done # ← Unchanged (already done)
priority: 9
assignee: alice
---More Examples:
Reassign tasks:
Action: FOR tasks WHERE assignee = "bob" SET assignee "alice", reassignedDate "{{today}}"Mark books finished:
Action: FOR readingList WHERE currentPage = pages SET status "finished", completedDate "{{today}}"Sort Object Arrays
Example: Sort Tasks by Priority
Input:
---
title: Project Tasks
tasks:
- name: Write tests
priority: 3
- name: Fix security issue
priority: 9
- name: Update README
priority: 1
- name: Review code
priority: 7
---Condition: (none needed)
Action: FOR tasks SORT BY priority DESC
Output:
---
title: Project Tasks
tasks:
- name: Fix security issue
priority: 9
- name: Review code
priority: 7
- name: Write tests
priority: 3
- name: Update README
priority: 1
---Prioritize Specific Items
What makes this unique: Move items based on properties without full sorting.
Example: Move High-Priority Items to Top
Input:
---
title: My Reading List
books:
- title: Casual Read
priority: normal
- title: Important Research
priority: high
- title: Quick Reference
priority: low
- title: Critical Paper
priority: high
---Condition: (none needed)
Action: FOR books WHERE priority = "high" MOVE TO START
Output:
---
title: My Reading List
books:
- title: Important Research # ← Moved to top
priority: high
- title: Critical Paper # ← Moved to top
priority: high
- title: Casual Read # ← Stays below
priority: normal
- title: Quick Reference # ← Stays at bottom
priority: low
---More Examples:
Move unwatched movies to top:
Action: FOR watchlist WHERE watched = false MOVE TO STARTMove completed tasks to end:
Action: FOR tasks WHERE status = "done" MOVE TO ENDMove urgent items after specific item:
Action: FOR tasks WHERE priority = "urgent" MOVE TO AFTER name = "Planning meeting"Multi-Step Workflow
Example: Update and Organize Tasks
Input:
---
title: Sprint Tasks
tasks:
- name: Bug fix
status: pending
points: 3
- name: New feature
status: in-progress
points: 8
- name: Code review
status: pending
points: 2
---Step 1 - Mark small pending tasks as quick-wins:
Action: FOR tasks WHERE status = "pending" AND points <= 3 SET status "quick-win"
Step 2 - Move quick-wins to top:
Action: FOR tasks WHERE status = "quick-win" MOVE TO START
Step 3 - Sort remaining by points:
Action: FOR tasks SORT BY points DESC
Final Output:
---
title: Sprint Tasks
tasks:
- name: Bug fix # ← Quick-win at top
status: quick-win
points: 3
- name: Code review # ← Quick-win at top
status: quick-win
points: 2
- name: New feature # ← Sorted by points
status: in-progress
points: 8
---Understanding Array Types
Scalar arrays (simple values):
tags: [project, active, urgent]
categories: [work, personal]- Operations:
ADD,REMOVE_ALL,REMOVE_ANY,SORT,DEDUPLICATE,MOVE, etc. - Target: The values themselves
Object arrays (structured data):
tasks:
- name: Task 1
status: pending
priority: 8- Operations:
FOR array WHERE condition SET,FOR array WHERE condition MOVE,FOR array SORT BY - Target: Specific objects based on their properties
See Actions for complete operation reference.
Advanced Operators
Powerful Features
These examples showcase advanced condition operators that provide precise querying, type validation, and nested array filtering capabilities.
Using .length - Count and Filter
Find notes with many tags:
Input:
---
title: Popular Article
tags: [javascript, typescript, react, vue, angular, svelte, node, deno]
---Condition: tags.length >= 5
Action: FOR tags APPEND "well-tagged"
Output:
---
title: Popular Article
tags: [javascript, typescript, react, vue, angular, svelte, node, deno, well-tagged]
---Find short titles that need expansion:
Input:
---
title: API
status: draft
---Condition: title.length < 10 AND status = "draft"
Action: FOR tags APPEND "needs-better-title"
Output:
---
title: API
status: draft
tags: [needs-better-title]
---Count metadata fields:
Input:
---
title: Minimal Note
author: Alice
---Condition: metadata.length < 5
Where metadata is treated as an object, this checks the number of keys.
Using empty / !empty - Detect Empty Values
Clean up empty tags arrays:
Input:
---
title: Note
tags: []
status: active
---Condition: tags empty
Action: DELETE tags
Output:
---
title: Note
status: active
---Find notes with actual content:
Input:
---
title: Draft
content: ""
---Condition: content empty AND NOT HAS published_date
Action: FOR tags APPEND "empty-draft"
Output:
---
title: Draft
content: ""
tags: [empty-draft]
---Distinguish between missing and empty:
# File 1: tags not present
# tags empty → false (can't be empty if doesn't exist)
# tags exists → false
# File 2: tags: []
# tags empty → true
# tags exists → true
# File 3: tags: null
# tags empty → false (null ≠ empty)
# tags :null → trueUsing Type Checking - Normalize Data
Convert string tags to arrays:
Input:
---
title: Legacy Note
tags: "old-format-tag"
---Condition: tags exists AND tags !:array
Action:
SET tags ["legacy", "{{fm:tags}}"]Output:
---
title: Legacy Note
tags: [legacy, old-format-tag]
---Find notes with numeric status (should be string):
Input:
---
title: Broken Note
status: 1
---Condition: status :number
Action: SET status "active"
Output:
---
title: Broken Note
status: active
---Validate required field types:
Condition: priority exists AND priority !:number
Action: DELETE priority
This finds and removes priority fields that aren't numbers.
Using ANY / ALL - Query Nested Data
Find notes with any active project:
Input:
---
title: Projects Dashboard
projects:
- name: Website Redesign
status: active
priority: 8
- name: Mobile App
status: pending
priority: 3
- name: API Refactor
status: planning
priority: 5
---Condition: ANY projects WHERE status = "active"
Action: FOR tags APPEND "has-active-projects"
Output:
---
title: Projects Dashboard
projects:
- name: Website Redesign
status: active
priority: 8
- name: Mobile App
status: pending
priority: 3
- name: API Refactor
status: planning
priority: 5
tags: [has-active-projects]
---Verify all tasks are assigned:
Input:
---
title: Sprint Board
tasks:
- name: Bug fix
assignee: alice
- name: Feature work
assignee: bob
- name: Testing
assignee: alice
---Condition: ALL tasks WHERE assignee exists
Action: FOR tags APPEND "fully-assigned"
Combine ANY with high priority:
Input:
---
title: Urgent Projects
projects:
- name: Security Patch
priority: 10
status: active
- name: Documentation
priority: 2
status: active
---Condition: ANY projects WHERE priority > 8
Action: SET urgent true
Output:
---
title: Urgent Projects
urgent: true
projects:
- name: Security Patch
priority: 10
status: active
- name: Documentation
priority: 2
status: active
---Nested quantifiers - Find files with pending work:
Input:
---
title: Team Workload
teams:
- name: Backend
tasks:
- status: done
- status: done
- name: Frontend
tasks:
- status: pending
- status: done
---Condition: ANY teams WHERE ANY tasks WHERE status = "pending"
Action: FOR tags APPEND "has-pending-work"
Explanation: Searches through teams, and for each team, checks if ANY of its tasks are pending. If any team has pending tasks, the condition matches.
Using Negative Indexing - Access from End
Access array items from the end without knowing the array length.
Check last task completion:
Input:
---
title: Project Tasks
tasks:
- name: Setup
status: done
- name: Development
status: done
- name: Testing
status: pending
---Condition: tasks[-1].status = "done"
Result: Condition is false (last task is "pending")
Update most recent entry:
Input:
---
title: Activity Log
history:
- date: 2025-01-01
event: Created
reviewed: false
- date: 2025-01-05
event: Updated
reviewed: false
---Condition: history[-1].reviewed = false
Action: FOR history[-1] SET reviewed true
Output:
---
title: Activity Log
history:
- date: 2025-01-01
event: Created
reviewed: false
- date: 2025-01-05
event: Updated
reviewed: true # ← Last entry updated
---Insert before last item:
Input:
---
title: Tag Management
tags: [project, active, important, final]
---Action: FOR tags INSERT "archived" AT -2
Output:
---
title: Tag Management
tags: [project, active, important, archived, final]
# ↑ inserted before last
---Access nested arrays from end:
Input:
---
title: Multi-Project Dashboard
projects:
- name: Alpha
tasks:
- id: T1
priority: 5
- id: T2
priority: 9
- name: Beta
tasks:
- id: T3
priority: 2
---Condition: projects[-1].tasks[-1].priority < 5
Action: SET needs_attention true
Result: Condition is true (Beta's last task has priority 2)
Use cases:
- Process most recent log entries
- Check latest task status
- Update final array elements
- Insert items relative to end
Relative Positioning - MOVE TO AFTER/BEFORE
Position items relative to other items in the array without full sorting.
Prioritize urgent tasks after planning:
Input:
---
title: Sprint Tasks
tasks:
- name: Sprint Planning
type: planning
priority: normal
- name: Code Review
type: review
priority: normal
- name: Security Patch
type: hotfix
priority: critical
- name: Feature Development
type: development
priority: normal
- name: Testing
type: qa
priority: low
---Condition: ANY tasks WHERE priority = "critical"
Action: FOR tasks WHERE priority = "critical" MOVE TO AFTER type = "planning"
Output:
---
title: Sprint Tasks
tasks:
- name: Sprint Planning
type: planning
priority: normal
- name: Security Patch # ← Moved right after planning
type: hotfix
priority: critical
- name: Code Review # ← Pushed down
type: review
priority: normal
- name: Feature Development
type: development
priority: normal
- name: Testing
type: qa
priority: low
---Insert review step before deployment:
Input:
---
title: Release Workflow
steps:
- name: Build
status: completed
- name: Deployment
status: pending
- name: QA Review
status: pending
---Action: FOR steps WHERE name = "QA Review" MOVE TO BEFORE name = "Deployment"
Output:
---
title: Release Workflow
steps:
- name: Build
status: completed
- name: QA Review # ← Moved before deployment
status: pending
- name: Deployment # ← Now comes after review
status: pending
---Group related items together:
Input:
---
title: Documentation Tasks
items:
- category: Setup
task: Installation
- category: Advanced
task: Custom Config
- category: Setup
task: Quick Start
- category: Reference
task: API Docs
- category: Setup
task: Prerequisites
---Action: FOR items WHERE category = "Setup" MOVE TO START
Output:
---
title: Documentation Tasks
items:
- category: Setup # ← All Setup items
task: Installation # grouped at start
- category: Setup
task: Quick Start
- category: Setup
task: Prerequisites
- category: Advanced # ← Other categories below
task: Custom Config
- category: Reference
task: API Docs
---Use cases:
- Position urgent work after planning
- Enforce workflow ordering (review before deployment)
- Group related items without full sort
- Maintain manual ordering with selective positioning
Working with Deeply Nested Data
Access and modify complex multi-level structures.
Multi-level object paths:
Input:
---
title: User Profile
metadata:
author:
profile:
name: Alice Johnson
verified: false
contact:
email: alice@example.com
phone: +1-555-0123
---Condition: metadata.author.profile.verified = false
Action: SET metadata.author.profile.verified true
Output:
---
title: User Profile
metadata:
author:
profile:
name: Alice Johnson
verified: true # ← Updated deep nested field
contact:
email: alice@example.com
phone: +1-555-0123
---Nested arrays within objects:
Input:
---
title: Project Management
projects:
- name: Website
phases:
- name: Design
tasks:
- id: T1
title: Wireframes
status: done
assignee: Alice
- id: T2
title: Mockups
status: pending
assignee: Bob
- name: Development
tasks:
- id: T3
title: Backend API
status: pending
assignee: Alice
---Condition: projects[0].phases[0].tasks[0].assignee = "Alice"
Action: FOR projects[0].phases[0].tasks WHERE status = "pending" SET status "active", started ""
Output:
---
title: Project Management
projects:
- name: Website
phases:
- name: Design
tasks:
- id: T1
title: Wireframes
status: done
assignee: Alice
- id: T2
title: Mockups
status: active # ← Updated
started: "2026-01-06" # ← Added
assignee: Bob
- name: Development
tasks:
- id: T3
title: Backend API
status: pending
assignee: Alice
---Complex nested API configuration:
Input:
---
title: API Configuration
config:
services:
- name: prod-api
region: us-east
endpoints:
- path: /api/v1/users
methods: [GET, POST]
rateLimit: 1000
auth: required
- path: /api/v1/posts
methods: [GET, POST, PUT, DELETE]
rateLimit: 500
auth: required
---Condition: config.services[0].endpoints[0].rateLimit < 2000
Action: SET config.services[0].endpoints[0].rateLimit 5000
Output:
---
title: API Configuration
config:
services:
- name: prod-api
region: us-east
endpoints:
- path: /api/v1/users
methods: [GET, POST]
rateLimit: 5000 # ← Updated nested value
auth: required
- path: /api/v1/posts
methods: [GET, POST, PUT, DELETE]
rateLimit: 500
auth: required
---Combine with negative indexing:
Input:
---
title: Team Structure
teams:
- name: Backend
members:
- name: Alice
role: senior
active: true
- name: Bob
role: junior
active: false
- name: Frontend
members:
- name: Charlie
role: lead
active: true
---Condition: teams[-1].members[-1].role = "lead"
Action: FOR teams[-1].members[-1] SET badge "team-lead"
Output:
---
title: Team Structure
teams:
- name: Backend
members:
- name: Alice
role: senior
active: true
- name: Bob
role: junior
active: false
- name: Frontend
members:
- name: Charlie
role: lead
active: true
badge: team-lead # ← Added to last team's last member
---Use cases:
- Manage complex configuration structures
- Update nested project/task hierarchies
- Access deeply nested API settings
- Modify multi-level organizational data
Data Quality:
- Clean and deduplicate
- Normalize formats
- Validate completeness
- Add derived metadata
Best Practices:
- Test workflows on single files first
- Use dry run to preview changes
- Keep related operations together
- Document complex workflows
- Break extremely long chains into multiple rules
Direct Element Access
Update specific array elements by their index position.
Update Last Item in Array
Input:
---
title: Reading List
books:
- title: "Book 1"
read: false
- title: "Book 2"
read: false
---Condition: (none - direct element access doesn't need conditions)
Action: FOR books[-1] SET read true
Output:
---
title: Reading List
books:
- title: "Book 1"
read: false
- title: "Book 2"
read: true
---Use case: Mark the most recently added book as read without conditional logic.
Update Nested Array Element
Input:
---
projects:
- name: "Project A"
teams:
- name: "Frontend"
lead: "Alice"
- name: "Backend"
lead: "Bob"
---Condition: (none)
Action: FOR projects[0].teams[-1] SET lead "Charlie"
Output:
---
projects:
- name: "Project A"
teams:
- name: "Frontend"
lead: "Alice"
- name: "Backend"
lead: "Charlie"
---Use case: Direct path navigation with negative indices for precise element targeting.
Complete Feature Coverage
Scalar Operations
ADD - Append to Field
Input:
---
title: Project Status
notes: "Initial draft completed"
---Condition: HAS notes
Action: ADD notes " - Updated 2025-02-04"
Output:
---
title: Project Status
notes: "Initial draft completed - Updated 2025-02-04"
---RENAME - Rename Field
Input:
---
title: Task Board
priority: 8
status: active
---Condition: HAS priority
Action: RENAME priority TO importance
Output:
---
title: Task Board
importance: 8
status: active
---DECREMENT - Decrease Numeric Value
Input:
---
title: Inventory
stock: 50
location: warehouse
---Condition: stock > 0
Action: DECREMENT stock 5
Output:
---
title: Inventory
stock: 45
location: warehouse
---Array Operations - Simple
FOR...PREPEND - Add to Start of Array
Input:
---
title: Daily Schedule
tasks:
- name: Code review
time: "10:00"
- name: Standup
time: "10:30"
---Action: FOR tasks PREPEND "morning-standup"
Output:
---
title: Daily Schedule
tasks:
- morning-standup
- name: Code review
time: "10:00"
- name: Standup
time: "10:30"
---FOR...INSERT AT - Insert at Specific Position
Input:
---
title: Feature Tags
tags: [backend, frontend, critical]
---Action: FOR tags INSERT "urgent" AT 1
Output:
---
title: Feature Tags
tags: [backend, urgent, frontend, critical]
---FOR...DEDUPLICATE - Remove Duplicate Values
Input:
---
title: Bug Report
keywords: [bug, fix, urgent, bug, critical, urgent, bug]
---Action: FOR keywords DEDUPLICATE
Output:
---
title: Bug Report
keywords: [bug, fix, urgent, critical]
---Object Operations
FOR...MERGE - Merge Objects
Input:
---
title: Document
metadata:
author: Alice
created: "2025-01-15"
---Action: FOR metadata MERGE {"reviewed": true, "updated": "2025-02-04"}
Output:
---
title: Document
metadata:
author: Alice
created: "2025-01-15"
reviewed: true
updated: "2025-02-04"
---FOR...MERGE_OVERWRITE - Merge with Override
Input:
---
title: App Config
settings:
theme: light
fontSize: 12
notifications: true
---Action: FOR settings MERGE_OVERWRITE {"theme": "dark", "fontSize": 14}
Output:
---
title: App Config
settings:
theme: dark
fontSize: 14
notifications: true
---Condition Operations
OR - Logical OR Operator
Input:
---
title: Task
status: draft
priority: 7
---Condition: status = "draft" OR status = "pending"
Action: SET priority 10
Output:
---
title: Task
status: draft
priority: 10
---Path exists - Check Field Existence (Postfix)
Input:
---
title: Article
author: Alice Johnson
content: "Complete article text here"
---Condition: author exists
Action: FOR tags APPEND "has-author"
Output:
---
title: Article
author: Alice Johnson
content: "Complete article text here"
tags: [has-author]
---IN - Value in Array
Input:
---
title: Workflow
status: active
priority: 5
---Condition: status IN ["active", "pending", "in-progress"]
Action: FOR tags APPEND "in-workflow"
Output:
---
title: Workflow
status: active
priority: 5
tags: [in-workflow]
---ALL - All Elements Match Condition
Input:
---
title: Team Tasks
tasks:
- name: Task 1
assignee: alice
- name: Task 2
assignee: bob
- name: Task 3
assignee: charlie
---Condition: ALL tasks WHERE assignee exists
Action: FOR tags APPEND "fully-assigned"
Output:
---
title: Team Tasks
tasks:
- name: Task 1
assignee: alice
- name: Task 2
assignee: bob
- name: Task 3
assignee: charlie
tags: [fully-assigned]
---