Moving inline fields to frontmatter. Transitioning to Properties Manager

Until now, I stored all my metadata with a list of inline fields (key:: value) directly in the .md file.
Now with the (amazing) new properties feature in obsmd 1.4, I want to move all of my existing metadata in to the frontmatter and be compatible with the properties manager.

Has somebody found a way to make this an automated process?
So dedecting and moving inline fields in to the frontmatter, changing the double colon to a single one and wraping the internal links with quotation marks.

The Linter plug-in can be used to move tags into the frontmatter, but until now lacks the ability for inline fields.

This could probably be achieved with a script, but unfortunately I lack any programming ability :roll_eyes: I think I’m not the only one who had this method for metadata till now, so I think it could be useful not just for me!

Really happy about tips and tools! :slight_smile:

2 Likes

I’ve added a comment to the (longer) existing FR for this functionality to the Linter plug-in.

If anyone would also like to see the feature in Linter, you could leave a +1 :slight_smile:

4 Likes

There are some Python tools but I’ve never tried them. Look up on the forum: YAML Python conversion. I remember at least two threads/tools. Not sure if there’s a non-Python way.

I found it: GitHub - selimrbd/py-obsidianmd: Python interface to your Obsidian notes
Thank you! This could do the trick :slight_smile:

2 Likes

Gesundheit.

Hey @FriSti !

I’m having exactly the same issue than you. I tried the py-obsidian package, but when converting inline to frontmatter:

key:: [[link_to_another_page]]

I end up with:

---
key: [[link_to_another_page]]
---

Problem with that is that new Obsidian Properties will not recognise it as a link. The link must be enclosed in quotation marks. Did you find any function in the package that could make the trick?

Expected behaviour:

---
key: "[[link_to_another_page]]"
---

Cheers!

Post-processing regex changes can also be done in VSCode/Notepad++, etc. Must toggle regex on.

Match: ^key:\s(\[\[.*?\]\])$
Replace: key: "$1"
If you have a few different keys, it’s easy to do, but if you have dozens or hundreds of different keys, you need to capture each key with regular expression again.

Hey @gino_m !
Yes, I had thought of doing find and replace, but it may take me too much time as I already have over a hundred keys. I think py-obsidian, or using obsidian linter are the best tools. But seems that none supports this move yet…

Match: ^(.*?):\s(\[\[.*?\]\])$
Replace: $1: "$2"

  • I could have given you this solution straight away, but I don’t see your files. This will make replacements on all lines in and outside of your YAML.

A more stringent way to target YAML keys only would be to go for keys starting with a lowercase character – that’s if your keys are all lowercase strings (as is the case in my vault). Then:
Match: ^([a-zžáàäæãééíóöőüűčñßðđŋħjł].*?):\s(\[\[.*?\]\])$
Replace: $1: "$2"

…in which case a main body line such as–
See here: [[somefilename]]
…won’t be changed to:
See here: "[[somefilename]]"

Another way would be to target single-string keys (my keys are never two or three words and are always lowercase).
In the following page, I make targets for various cases for 2 and 3-string variations as well with the OR operator:

  • Should be okay to use.
    (Make a backup of your vault and see what happens. Then report back, if you want.)

@gino_m it worked like a charm! I also had some keys followed by two links, but it was simple to solve following your example.

Thanks!

1 Like

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