Batch add front matter

I’m looking to add a standard front matter template to imported notes and then work through updating the metadata. Are there any tools or scripts to go through and insert text at the beginning of a batch of files? I was looking at VSCode which can obviously do a search and replace across multiple files but I couldn’t see an easy option to just insert text.

I’m using Mac so Automator / Scripting / Alfred etc. are all possibilities.

1 Like

Sorry you haven’t gotten any answers on this. So I had the same problem, but my solution might be too technical. You can write a script in the language of your choice (python, javascript, etc.) to add lines to all your notes. Obsidian is going to format frontmatter bounded by --- in an upcoming version.

1 Like

You can do it in VS Code. I wouldn’t say it’s simple, but doable.

:warning: Please, test this before using it on actual notes, and don’t forget to backup. :warning:

Find (in regex mode): ^(?<![\s\S\r])
Replace: ---\nkey1: value1\nkey2: value2\n---\n\n

Edit keys and values according to your needs, separating each line with \n.

5 Likes

@ajgxyz Do you still have this issue? If you don’t want to write a script, @macedotavares’s solution should help.

Yep, the regex suggestion worked perfectly. I’m still figuring out regex but it’s really useful. Thanks @macedotavares!

1 Like

Anyone know if this is doable on LInux without writing a script? I’m using atom.

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