Last active
January 22, 2024 11:11
-
-
Save ScottJWalter/a6d248acaf54d0d53115d7e0ddb1f6d3 to your computer and use it in GitHub Desktop.
Resets an obsidian installation on Windows to not auto-launch any vault, taking you to vault selection. #obsidian #windows
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
@echo off | |
setlocal enabledelayedexpansion | |
rem This script assumes that it's running in the obsidian configuration | |
rem directory, which is usually at | |
rem | |
rem %USERPROFILE%\AppData\Roaming\obsidian | |
rem | |
rem Where %USERPROFILE% is your user name | |
rem | |
rem It also requires that 'jq' be installed on the system. Get it here: | |
rem https://jqlang.github.io/jq/ | |
rem | |
rem This script extracts a list of keys (the vault IDs), then loops through | |
rem them, resetting each JSON object. | |
C: | |
cd %USERPROFILE%\AppData\Roaming\obsidian | |
set lf=- | |
for /f "delims=" %%v in ('type obsidian.json ^| jq -n "input[] | keys[]"') do ( | |
rem because each vault can have its own "open" property, and because you can't | |
rem "batch change" multiple keys in different subtrees in the JSON with jq, | |
rem we need to do this one vault at a time. | |
type obsidian.json | jq ".vaults[\"%%v\"].open = false" > obsidian.json.new | |
del obsidian.json | |
ren obsidian.json.new obsidian.json | |
) | |
rem At this point, you would run obsidian to bring up the vault selector | |
rem use 'start' to launch obsidian and close this batch window (if you set the | |
rem shortcut to run minimized, you won't even see it. | |
rem | |
rem Also, you're path may vary (remember to replace <USER> with your user name. | |
rem And yes, the .EXE and .JSON are stored in separate folders. | |
start %USERPROFILE%\AppData\Local\Obsidian\Obsidian.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to use %USERPROFILE%, so (assuming a default Windows install), you shouldn't need to modify any file paths. This should be a drag-drop-use script.
To slip this into your flow, edit the Obsidian shortcut on your desktop to launch this batch file instead. It'll kill the auto-opens and fire obsidian, taking you to the vault selector.