用 mdfind 按日期查找文件($time 语法)

mdfind 直接暴露 Spotlight 索引中的日期元数据(如 kMDItemContentModificationDate),并可与 $time.today、$time.this_week 等内置时间常量组合使用。

macOS日期mdfind Spotlight 搜索聚焦搜索低风险
运行 `mdfind 'kMDItemContentModificationDate >= $time.this_week'` 即可列出最近一周内修改过的所有已索引文件。

01命令

命令
$ mdfind 'kMDItemContentModificationDate >= $time.this_week'
mdfind 'kMDItemContentCreationDate >= $time.yesterday && kMDItemFSName == "*.pdf"'

02作用说明

日期比较既支持 ISO 8601 字符串,也支持内置 $time 常量($time.today、$time.yesterday、$time.this_week、$time.this_month)。日期条件可以用 && 与其他 Spotlight 谓词组合,在同一个查询里按文件名或类型进一步收窄范围。

03风险

风险低风险
使用条件Spotlight indexing must be enabled for the volumes being searched
!注意: 结果完全依赖 Spotlight 索引;被排除在 Spotlight 之外的文件夹(包括许多点目录)中的文件不会出现。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

最后验证: 2026-09-17 · 分类: 文件与文件夹

06相关方案