Best way to refactor/standardize frontmatter in daily notes?

Hi Obsidian Community,

I am hoping to get some advice on the best/most simple way to go about a bulk refactoring of (years) of Daily notes. My guess is that I’m not the first person to attempt this, but I haven’t found any helpful forum posts yet. I’d definitely appreciate some advice from someone who has done this!

What I’m trying to do

In refactoring, there are a few things I’d like to accomplish. But mainly, I would like to standardize the frontmatter fields so that I can run other scripts to augment and organize my notes.

Objectives:

  1. I have a templater template file that contains a set of fields. I would like to programmatically/bulk apply this template to past daily note files. Here is the logic: (1) if there are existing/matching metadata fields, keep the metadata values. (2) Add any missing metadata fields to the note that exist in the master template file. (3) Remove any metadata fields that don’t match by moving them to inline/footer section or deleting (based on script config). Essentially, I’d like to do a merge.
  2. In the master daily note template, there is a script to populate the “date” property with the date (<% tp.file.title %>). I’d like to execute the Templater command “Replace templates in the active file” to populate that field with the daily note title (all dates formatted in ISO-8601). Is there a way to do this in bulk once the frontmatters are synced?
  3. (Bonus) - I’d like to add a “date” metadata field to all my notes, because the integrated f.mday metadata is not accessible by the OS and other scripts I’d like to build. Is there a way to run this script, similar to (2), only populating this field from the Obsidian file metadata?

Things I have tried

  1. Familiar with dataview, which is great for querying a list of files to operate on, but Dataview is essentially a read-only tool. I’m not sure how to use it in conjunction with templater properly.
  2. I have found the packages “obsidian-tools” and “py-obsidian”. Between these two, seems like it would be a somewhat simple python script to write, but the problem is that any external script doesn’t have access to implicit file metadata, which I’d really like to leverage.
  3. Starting to explore advanced templater functions but I am not familiar with it.
  4. Could use bash/shell scripting (grep, awk, etc), but this gets me even further away from the Obsidian environment, and has the same problem not being able to access implicit file metadata as python scripts.

I’d love to see this feature as well! I don’t have lots of expertise, but I’d be curious to see if there’s other plugins and/or scripts that can help with this.

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