Last active
October 18, 2024 13:48
-
-
Save reagle/e6da63b553662bd1554dabc5ed6661b8 to your computer and use it in GitHub Desktop.
Create symbolic links from source Obsidian vault config to target vaults.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Create symbolic links from main Obsidian vault config to other vaults. | |
Obsidian configuration folder can be copied between vaults; this script | |
copies a configuration from a main vault to other vaults. | |
""" | |
from pathlib import Path | |
from shutil import copytree, rmtree | |
main = Path("~/data/2web/reagle.org/joseph/plan/ob-plan/.obsidian").expanduser() | |
others = [ | |
Path(t).expanduser() | |
for t in [ | |
"~/data/2misc/ob-misc/.obsidian", | |
"~/data/2web/reagle.org/joseph/ob-codex/.obsidian", | |
"~/data/mom/ob-mom/.obsidian", | |
] | |
] | |
print(f"{main=}") | |
for other in others: | |
print(f"checking {other=}") | |
if other.exists(): | |
if other.is_symlink(): | |
other.unlink() | |
print(f" unlinked {other=}") | |
elif other.is_dir(): | |
rmtree(other) | |
print(f" removed {other=}") | |
else: | |
raise TypeError(f" unknown type: {other}") | |
else: | |
print(f" doesn't exist yet {other=}") | |
copytree(main, other) | |
print(f" copied to {other=}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks ☕️, super handy.