用 mdfind 的原始 Spotlight 语法搜索
通过 kMDItem 元数据属性搜索 Spotlight 界面无法表达的条件,速度远快于 find。
运行 `mdfind 'kMDItemAuthor == "Jane"'`,或组合 `kMDItemPixelWidth > 4000` 这类属性做即时元数据搜索。
01命令
命令
$ mdfind 'kMDItemPixelWidth > 4000 && kMDItemContentTypeTree == "public.image"'02作用说明
mdfind 直接查询 Spotlight 索引,即使面对数百万文件也能毫秒级返回。原始谓词语法暴露了数百个 kMDItem 属性:内容类型、EXIF 尺寸、PDF 作者、ISO 日期等。加 -onlyin 可限定目录,-live 可实时观察匹配变化;若某个文件匹配不上,可用 `mdimport -t -d2` 调试。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- macOS mdfind — find files by raw Spotlight query依据: Documents mdfind's raw query strings, -onlyin, -name and -live flags.
最后验证: 2026-09-17 · 分类: 系统与设置