I need to change my YAML setup. Having 1500 notes, the manual route isn’t that appealing. What would you suggest?
This is what I have
---
titel: A note title
taggar: #atag #asecondtag
zid: [[202012151052 A note title|A note title]]
källa: <url>
---
And this is what I want:
---
title: A note title
tags: [atag, asecondtag]
zid: 202012151052
source: <url>
---
So, one the first line, changing “titel” into “title”. On the second, chagning “taggar” into “tags” and changing the tagging syntax. On the third, just keeping the unique id. And on the fourth, chagning “källa” into “source”.
I guess Regex and something like SublimeText are the tools I need?
You can easily do it using a small script with regular expressions and replacing it with the format you want, kinda like i suggested for your other question.
Backup your vault again and perform these replacements. After each one, go through your notes (if you have too many, just a nice random sample) to make sure there are no unexpected results. There probably will be.
1. Note titles
This assumes that the note title is exactly repeated in three places.
Let me start by stating very clearly that I’m not even an intermediate regex user. I’m not being modest, here. It’s just that regex is so powerful that even a beginner can do amazing things.
I started to learn regex out of necessity, while doing some text cleanup that would otherwise be very tiresome. I found it so useful (and so much fun) that I kind of took it as a game I regularly play.
My advice is to start with practical examples; real-world problems, preferably something close to an immediate need of yours. Like finding all e-mail addresses in your vault. Or all dates. Checkout these awesome playgrounds:
They both contain lots of example patterns, they both explain to you what part of the expression is doing what. So just pick one (or both) and go crazy.
VS Code has very robust Regex capabilities (others too, but I prefer this one); opening a file and hitting Cmd+Shift+F will allow you to experiment freely (on your own, though).
This may seem dumb, but only after getting the very basics, I’d go over a tutorial. Rexegg has one of the best.
When you start to feel more confident, you can play Regex Golf, where the goal is to build the smallest possible expression that satisfies some given conditions.
thanks a lot @macedotavares for the awesome helpful reply. It helps a lot and I can’t to start practicing it! I appreciate the awesome suggestions, I’ll take on your offer and reach out if I need help!
When I did a test run on a small sample two weeks ago, this part worked. But when I now try to do the large bulk of my notes, this step doesn’t match anything in my notes.
This is what my tag-line looks like in my YAML after the first pass
I just tested this in VS Code and a strange thing happens: if I perform a simple “Find” (Cmd+F), it works as expected; however, “Find in Files” (Cmd+Shift+F) throws the error
Regex parse error: lookbehind assertion is not fixed length.
Well, indeed it is not. But that didn’t seem to bother VSC 15 days ago.
I don’t know if this is something that got broken with a VSC update, or if I’m missing something. Anyway, let me see if I can come up with an alternative expression.
For members who may be looking to edit YAML as a Database or Table-like view, Obsidian DB Folder has been a helpful extension for me to see YAML of files in a folder in a Notion-Like database.
For bulk edits, I would still recommend using regex or a Python script using the Frontmatter Module, and Obsidian DB Folder is useful for visualizing YAML metadata.