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 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!
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’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?
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…
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.)