MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / countMdFilesRecursively

Function countMdFilesRecursively

apps/desktop/src/mcp/vault-ops.ts:88–103  ·  view source on GitHub ↗

Recursively count .md files under a given directory. Used to see * whether ` /inbox/` actually has content.

(dir: string)

Source from the content-addressed store, hash-verified

86/** Recursively count .md files under a given directory. Used to see
87 * whether `<root>/inbox/` actually has content. */
88async function countMdFilesRecursively(dir: string): Promise<number> {
89 let entries: import('node:fs').Dirent[]
90 try {
91 entries = await fs.readdir(dir, { withFileTypes: true })
92 } catch {
93 return 0
94 }
95 let count = 0
96 for (const entry of entries) {
97 if (entry.name.startsWith('.')) continue
98 const full = path.join(dir, entry.name)
99 if (entry.isDirectory()) count += await countMdFilesRecursively(full)
100 else if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) count += 1
101 }
102 return count
103}
104
105/** Decide whether this vault uses inbox-mode or root-mode for its
106 * primary notes area. The vault's on-disk layout is the strongest

Callers 1

readPrimaryNotesLocationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected