python library for ObsidianMD
Project description
Python utilities for the personal knowledge management tool Obsidian
Motivation
I wanted to modify my notes' metadata in batch and couldn't find an existing plugin to do so. If some of the functionalities you see here are already available in a plugin, please let me know. Open for contributions.
Current features
- Create a Note object from a file path, that has a 'frontmatter', 'metadata', and 'tags' attributes
- Add / remove tags from the note
- Write back the updated note to disk
Warnings
- This code hasn't been much tested yet, use at your own peril
- This code only handles tags present in the frontmatter, not the note body
Basic usage
path = Path('path/to/file')
note = Note(path)
## print frontmatter
print(note.frontmatter)
## get the note's metadata (from frontmatter) as a dict
note.metadata
## get list of tags
print(note.tags)
## add a tag
note.add_tag('tag_name')
## remove a tag
note.remove_tag('tag_name')
## write the note with the updated metadata
note.write()
Original motivation: add a tag to all files in a folder
import os
from pathlib import Path
from source.note import Note
path_dir = Path('path/to/dir')
for r,d,fls in os.walk(path_dir):
for f in fls:
pth = Path(r)/f
note = Note(pth)
note.add_tag('tag_name')
note.write()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-obsidianmd-0.1.2.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for py_obsidianmd-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce043eebe7efab59d28e98b4c9d05f9cace77738b9f0a23f0c802a0d163d42f0 |
|
MD5 | 8ad3ca9574736f8d1e22737aef3e4b30 |
|
BLAKE2b-256 | 041afa8e52fedfd61f9902a048ce5bff0b9066cf2f5df81406af56841f2ac9a3 |