Obsidian Metadata Handler: a Python script

:warning: This script is in early alpha! Backup and version control your Obsidian files before attempting to run this script. :warning:
(First time poster.)
I’ve made a nifty little script which automatically fills out the created_date field in YAML metadata.
The main goal is if all the folder’s metadata is wiped, you’ll still have it in the YAML.
Here’s the link.
Could I get some feedback?
I plan on adding file_name and modified_date[1] fields as well.

[1]: Edit: modified_date is being worked on. modified_date is in the mostly complete stage.

2 Likes

got error here.

❯ python3 obsidian-metadata-handler/created.py -p "./test-vault"
test-vault/A file.md
Traceback (most recent call last):
  File "/Users/gaofeng/Code/opensource/obsidian-metadata-handler/obsidian-metadata-handler/created.py", line 30, in <module>
    if file["modified_date"] == True:
  File "/usr/local/lib/python3.9/site-packages/frontmatter/__init__.py", line 275, in __getitem__
    return self.metadata[name]
KeyError: 'modified_date'

Thanks for reporting the error, @lifesign!

I’ve gone ahead and logged the error on GitHub. Can we continue discussion there to avoid thread clutter?

Why not write it as a plugin?

A few reasons:

  • This is more to deal with a backlog of files without metadata.
  • I am highly incompetent when it comes to JavaScript and derivatives.
  • The script isn’t designed to be a replacement for Templater and co, which are better designed for doing things such as this, as far as retroactivity goes.
  • Sometimes people don’t want to open Obsidian just to update some metadata.

As of today, this script has been deprecated. Please find alternatives, as support and stability is no longer guaranteed.