1.7 KiB
OMG
OMG - Obsidian Metadata Generator
OMG is a simple python script that generates metadata like the "Metadata Extractor"-plugin does. It cannot do as much as the plugin because it was made to generate metadata for Perlite.
Setup
Before you can use the script, you have to install the dependencies. Normally, you would install the dependencies like this:
pip install -r requirements.txt
(which also works on this project)
But since OMG has only one dependency, (pyyaml) you can simply run
pip install pyyaml
Usage
Command Line
The script is usable from the command line. It takes 2 arguments: vault_path
and metadata_path
.
metadata_path
comes after vault_path
and is optional because it has a default value of vault_path/metadata.json
.
It is recommended to put the omg.py
into ~/bin/
and to make it executable with chmod +x ~/bin/omg.py
.
If you did that, you can now delete every other file that came with OMG. The script is now executable from everywhere.
Example usage:
cd ~/.obsidian/myVault
omg.py .
Python API
To use the script as a module, simply import it and create an instance of the OMG class with the path
-parameter set
to your vault path. The metadata is stored as a dict in instance.md_files
.
Example:
from omg import OMG
metadata = OMG("/home/user/.obsidian/myVault")
as_dict = metadata.md_files
To write the metadata, you can use instance.dump(path: Pathlike=None, indent=2)
.
This will create a metadata.json
in your vault by default, but you can also specify any other path.
Example:
from omg import OMG
metadata = OMG("/home/user/.obsidian/myVault")
metadata.dump()