delete_note
Remove notes from your Obsidian vault by specifying a file path, with options to permanently delete or move to trash for recovery.
Instructions
Delete a note (moves to vault trash by default)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Relative path to the note | |
| permanent | No | If true, permanently delete instead of moving to trash |
Implementation Reference
- src/lib/vault.ts:120-140 (handler)The actual logic for deleting a note, supporting both trash and permanent deletion.
export async function deleteNote( vaultPath: string, relativePath: string, useTrash = true, ): Promise<void> { const fullPath = resolveVaultPath(vaultPath, relativePath); if (useTrash) { const trashDir = path.join(vaultPath, ".trash"); const trashPath = path.join(trashDir, relativePath); const resolvedTrash = path.resolve(trashPath); const resolvedTrashDir = path.resolve(trashDir); if (!resolvedTrash.startsWith(resolvedTrashDir + path.sep) && resolvedTrash !== resolvedTrashDir) { throw new Error(`Invalid trash path: ${relativePath}`); } await fs.mkdir(path.dirname(trashPath), { recursive: true }); await fs.rename(fullPath, trashPath); } else { await fs.unlink(fullPath); } }