A python library for accessing and editing your Obsidian vault.
Warning
This library can easily make large changes to your vault which may be difficult to reverse. Make sure to have a backup of your vault before using OVault to modify it.
Check out the examples!
import ovault
# Open a vault at a given path
vault = ovault.Vault("test-vaults/simple_vault")
print("Vault Path :", vault.path)
print("Notes :", len(vault.notes()))
print("Attachments :", len(vault.attachments()))
print("Tags :", sorted(vault.tags()))
print()
# Get the note named 'first_note'
note = vault.note("first_note")
print("Note Name :", note.name)
print("Note Path :", note.path)
print("Note Tokens :", note.tokens())Output:
Vault Path : /home/balder/projects/ovault/test-vaults/simple_vault
Notes : 11
Attachments : 3
Tags : ['callout4youtag', 'frontmatter-tag1', 'frontmatter-tag2', 'linksaregood']
Note Name : first_note
Note Path : first_note.md
Note Tokens : [Header(# FIRST NOTE!), Text(Wuhuuuuuuuuuuu!Thi...), InternalLink(second note), Text(.Takes a look at t...), InternalLink(sub/todo), Text()]
OVault includes runnable modules for common tasks. Get an overview by running the ovault module:
python -m ovaultOutput:
OVault provies a few utilties out of the box.
You can run them like so: `python3 -m ovault.<module>`
Available modules:
ovault.visualize_graph : Visualize your Obsidian vault graph using pyvis.
ovault.check_links : Check all external links to websites in an Obsidian vault and report any broken links.
ovault.to_html : Convert an obsidian vault to a simple static HTML site.
ovault.mv : Rename a file within an Obsidian vault, updating all links accordingly.
ovault.info : Show information about an Obsidian vault.
ovault.name_pasted_images : Rename pasted images in the vault based on the note they are pasted into.
ovault.help : Show a list of all utility modules included in `ovault`.
ovault.filename_compatibility : Check filenames for compatibility across different operating systems.
pip install ovaultor locally
git pull https://github.com/BalderHolst/ovault
cd ovault
pip install .- Indexing: Automatically indexes all notes and attachments within the vault upon initialization.
- Ignored Files: Respects and parses
.vault-ignorefiles to exclude specified paths during indexing. - Dangling Links: Identify and list links within your notes that point to non-existent files.
- Access Notes & Attachments: Retrieve all notes or attachments in the vault as Python objects.
- Frontmatter Extraction: Manipulate YAML frontmatter from notes.
- Dynamic Note Modification: Programmatically insert or replace parts of a note
- List All Tags: Get a complete list of tags present in your vault.
- Filter by Tag: Retrieve all notes associated with a specific tag.
- Rich Token Representation: Notes are parsed into a detailed stream of
Tokenobjects, representing various markdown elements.
See Token in lexer/tokens.rs for all token definitions.
I would be more than happy if anyone finds this useful enough to add to, or modify this code.
Install ovault and development dependencies with
pip install -e ".[dev]"or use the nix flake
nix developmaturin develop --release --features python./scripts/test.shGenerate coverage report with
cargo tarpaulin --engine llvm --release --out Html./scripts/build-docs.py- Bump version in
Cargo.toml - Commit change and push
- Merge
devintomainand push - Create a git tag with the same version:
git tag <version> - Push new tag:
git push --tags