getFilesWithFrontmatterValue

getFilesWithFrontmatterValue(key: string, value: unknown): ReadonlySet<string>

Returns all files where the given frontmatter key has the given value.

Parameters

  • key — Frontmatter key name. Case-insensitive.
  • value — The value to match. Supports strings, numbers, booleans, Date objects, and individual array elements.

Returns

ReadonlySet<string> — vault-absolute file paths.

Value matching

Values are normalized for comparison:

YAML typeNormalizationQuery example
StringLowercasedgetFilesWithFrontmatterValue("status", "draft")
NumberString(n)getFilesWithFrontmatterValue("priority", 42)
BooleanString(b)getFilesWithFrontmatterValue("published", true)
Date (unquoted)toISOString()getFilesWithFrontmatterValue("created", new Date("2024-01-15"))
Array elementEach element indexed separatelygetFilesWithFrontmatterValue("tags", "project") matches tags: [project, todo]
Nested objectJSON.stringify().toLowerCase()Not recommended for querying

See Frontmatter Value Types for how Obsidian stores different YAML types.

Example

// Find all draft files
const drafts = cache.getFilesWithFrontmatterValue("status", "draft");
 
// Find files with a specific tag in frontmatter
const tagged = cache.getFilesWithFrontmatterValue("tags", "project");
 
// Find files created on a specific date
const created = cache.getFilesWithFrontmatterValue("created", new Date("2024-01-15"));