Created
June 20, 2025 11:50
-
-
Save tar80/0eb859b3ad9233d3c6ae02caa17aca8c to your computer and use it in GitHub Desktop.
PPx: パスがobsidian vault配下かどうかをチェックする
This file contains hidden or 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
var fso = PPx.CreateObject('Scripting.FileSystemObject'); | |
var OBSIDIAN_DIR = '.obsidian'; | |
var main = function main() { | |
var path = PPx.Arguments.Item(-1) || PPx.Extract('%FD') | |
return vaultRoot(path); | |
}; | |
/** | |
* pathを上行してOBSIDIAN_DIRを探す | |
* | |
* @param {string} path - 開始パス | |
* @returns {number} - vault配下なら1, 違うなら0を返す | |
*/ | |
var vaultRoot = function vaultRoot(path) { | |
var vault; | |
do { | |
vault = fso.BuildPath(path, OBSIDIAN_DIR); | |
if (fso.FolderExists(vault)) { | |
return 1; | |
} | |
path = fso.GetParentFolderName(path); | |
} while (path); | |
return 0; | |
}; | |
PPx.result = main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment