How to bulk restructure yaml frontmatter?

My goal

I have modified one template, and I want to sync other existing notes created from this template, to keep filtering result consistent.

original yaml

---
urgency: [1-5]
importance: [1-5]
interested: [1-5]
---

modified yaml: I want to change existing notes’ yaml to this

---
factor:
  urgency: [1-5]
  importance: [1-5]
  interested: [1-5]
---

action break up

  1. insert a attribute at top
  2. move 3 attributes 2 spaces

Things I have tried

I used \w{7,11}:\s\d{1}\n to match
urgency: [1-5]
importance: [1-5]
interested: [1-5]

don’t know how to do next.

If you have a text editor other than Obsidian that can do bulk find+replace, then backing up your vault and making the change in the other text editor is one option.

There may be ways to do this via community plugins as well: for example the Obsidian Linter plugin lets you add items to frontmatter in bulk and I think MetaEdit does as well. Check plugin settings carefully and back up your files before doing any bulk edits!

Wouldn’t it be the easiest way to match the whole block and …

urgency: [1-5]
importance: [1-5]
interested: [1-5]

… replace the whole block with your new block.

factor:
  urgency: [1-5]
  importance: [1-5]
  interested: [1-5]

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.