Skip to main content

Make batch updates to Obsidian metadata

Project description

Python Code Checker codecov

obsidian-metadata

A script to make batch updates to metadata in an Obsidian vault. Provides the following capabilities:

  • in-text tag: delete every occurrence
  • in-text tags: Rename tag (#tag1 -> #tag2)
  • frontmatter: Delete a key matching a regex pattern and all associated values
  • frontmatter: Rename a key
  • frontmatter: Delete a value matching a regex pattern from a specified key
  • frontmatter: Rename a value from a specified key
  • inline metadata: Delete a key matching a regex pattern and all associated values
  • inline metadata: Rename a key
  • inline metadata: Delete a value matching a regex pattern from a specified key
  • inline metadata: Rename a value from a specified key
  • vault: Create a backup of the Obsidian vault

Install

obsidian-metadata requires Python v3.10 or above.

pip install obsidian-metadata

Important Disclaimer

It is strongly recommended that you back up your vault prior to committing changes. This script makes changes directly to the markdown files in your vault. Once the changes are committed, there is no ability to recreate the original information unless you have a backup. Follow the instructions in the script to create a backup of your vault if needed. The author of this script is not responsible for any data loss that may occur. Use at your own risk.

Usage

The script provides a menu of available actions. Make as many changes as you require and review them as you go. No changes are made to the Vault until they are explicitly committed.

asciicast

Configuration

obsidian-metadata requires a configuration file at ~/.obsidian_metadata.toml. On first run, this file will be created. Read the comments in this file to configure your preferences. This configuration file contains the following information.

# Path to your obsidian vault
vault = "/path/to/vault"

# Folders within the vault to ignore when indexing metadata
exclude_paths = [".git", ".obsidian"]

Contributing

Setup: Once per project

There are two ways to contribute to this project.

21. Containerized development (Recommended)

  1. Clone this repository. git clone https://github.com/natelandau/obsidian-metadata
  2. Open the repository in Visual Studio Code
  3. Start the Dev Container. Run Ctrl/⌘ + + PRemote-Containers: Reopen in Container.
  4. Run poetry env info -p to find the PATH to the Python interpreter if needed by VSCode.

2. Local development

  1. Install Python 3.10 and Poetry
  2. Clone this repository. git clone https://github.com/natelandau/obsidian-metadata
  3. Install the Poetry environment with poetry install.
  4. Activate your Poetry environment with poetry shell.
  5. Install the pre-commit hooks with pre-commit install --install-hooks.

Developing

  • This project follows the Conventional Commits standard to automate Semantic Versioning and Keep A Changelog with Commitizen.
    • When you're ready to commit changes run cz c
  • Run poe from within the development environment to print a list of Poe the Poet tasks available to run on this project. Common commands:
    • poe lint runs all linters
    • poe test runs all tests with Pytest
  • Run poetry add {package} from within the development environment to install a run time dependency and add it to pyproject.toml and poetry.lock.
  • Run poetry remove {package} from within the development environment to uninstall a run time dependency and remove it from pyproject.toml and poetry.lock.
  • Run poetry update from within the development environment to upgrade all dependencies to the latest versions allowed by pyproject.toml.

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

obsidian_metadata-0.1.1.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

obsidian_metadata-0.1.1-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file obsidian_metadata-0.1.1.tar.gz.

File metadata

  • Download URL: obsidian_metadata-0.1.1.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-1031-azure

File hashes

Hashes for obsidian_metadata-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3e91bc30bade5526b6150638b4e092cd97af7881a17952343ccaf411341bc070
MD5 0ab974b64f4c438f42a0371fc4925bbf
BLAKE2b-256 a7744564408a6ab3f79e67b725fab311c5740c07b9961d1bc87ad0c23f0d3519

See more details on using hashes here.

File details

Details for the file obsidian_metadata-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: obsidian_metadata-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-1031-azure

File hashes

Hashes for obsidian_metadata-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c28a5ff907e99e96ffde326336c78323001b5710eb04b9a9a4402cb809fc7bbc
MD5 5d72060ed1ab49308a4651be38287262
BLAKE2b-256 5e81bb90dfb368936076d35311d0355a8f70d11aaff5c5ab35c9920c5b30e2ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page