Skip to content

How to add frontmatter to files not created by obsidian.nvim #335

Answered by epwalsh
sotte asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @sotte should be scriptable. Create a Lua file (tmp.lua) with something like this:

local scan = require("plenary.scandir")
local Note = require("obsidian.note")
local client = require("obsidian").get_client()

local paths = scan.scan_dir(tostring(client.dir), { search_pattern = ".*.md$" })
for _, path in ipairs(paths) do
	print(string.format("Updating note at %s...", path))
	local note = Note.from_file(path, client.dir)
	note:save()
end

Then from a buffer in your vault (obsidian.nvim needs to be loaded), run :luafile tmp.lua.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@epwalsh
Comment options

@epwalsh
Comment options

@sotte
Comment options

@sotte
Comment options

@theherk
Comment options

Answer selected by sotte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants