enquire-mcp API reference - v3.9.0-rc.4
    Preparing search index...

    Function renameNote

    • Atomic note rename with cross-vault backlink rewrite.

      Closes the longstanding "renaming breaks all backlinks" pain point. Walks every note, finds wikilinks / embeds whose findBestMatch resolves to the source file, rewrites only those literals (preserving |alias, #section, ^block, and the user's path-qualification convention), then atomically moves the file. dry_run returns the same plan without touching disk.

      Self-references inside the renamed file are also rewritten in the same pass — the file ships with no broken self-links. v3.7.13 M1 — write order is recoverable: (1) rewrite source content at OLD path → (2) fs.rename OLD → NEW (atomic, runs FIRST so a failure here doesn't leave updated backlinks pointing at a phantom target) → (3) rewrite backlink-bearing files (destination already exists on disk). Every failure mode is recoverable by re-running the same call (each step is idempotent on re-input). Pre-v3.7.13 the order was (backlinks → source → rename), which left backlinks rewritten to the NEW name pointing at a phantom destination when the rename step failed. WRITE TOOL — only registered when --enable-write is passed.

      Parameters

      • vault: Vault

        The vault. Must allow writes.

      • args: { dry_run?: boolean; from: string; overwrite?: boolean; to: string }

        from and to are vault-relative paths (with or without .md). dry_run defaults to false — when true, returns the plan without writing. overwrite defaults to false — when true, allows replacing an existing destination.

      Returns Promise<RenameNoteResult>

      A RenameNoteResult with per-file rewrites and totals.

      If source doesn't exist, destination exists and overwrite is false, source equals destination, or destination is privacy-excluded.

      If either path resolves outside the vault.

      // Preview first
      const plan = await renameNote(vault, {
      from: "Inbox/draft-1.md",
      to: "Posts/Hybrid Retrieval.md",
      dry_run: true
      });
      console.log(`Would update ${plan.files_updated.length} files`);

      // Apply
      await renameNote(vault, { from: "Inbox/draft-1.md", to: "Posts/Hybrid Retrieval.md" });