Skip to content

Instantly share code, notes, and snippets.

@tar80
Created June 20, 2025 11:50
Show Gist options
  • Save tar80/0eb859b3ad9233d3c6ae02caa17aca8c to your computer and use it in GitHub Desktop.
Save tar80/0eb859b3ad9233d3c6ae02caa17aca8c to your computer and use it in GitHub Desktop.
PPx: パスがobsidian vault配下かどうかをチェックする
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