Local Image Search
Search local images quickly using macOS Spotlight or fd.
Quick Start
Search by Name
CODEBLOCK0
Search by Date
CODEBLOCK1
Search by Location (GPS)
CODEBLOCK2
List All Images
CODEBLOCK3
Available Scripts
Basic Search
- -
scripts/search_by_name.sh - Search images by filename pattern - INLINECODE1 - Search by creation/modification date
- INLINECODE2 - List all images in a directory
Advanced Search
- -
scripts/search_by_location.sh - Search by GPS coordinates - INLINECODE4 - Search by image dimensions
- INLINECODE5 - Find visually similar images (requires perceptual hash)
Utility
- -
scripts/thumbnail.sh - Generate thumbnails for results - INLINECODE7 - Copy search results to destination
Image Types Supported
| Extension | Type |
|---|
| jpg/jpeg | JPEG images |
| png |
PNG images |
| heic | iPhone photos |
| webp | WebP images |
| gif | GIF images |
| tiff | TIFF images |
| raw | RAW camera files |
| dng | Digital negatives |
Metadata Search Keys
| Key | Description |
|---|
| kMDItemDisplayName | Filename |
| kMDItemFSContentChangeDate |
Modification date |
| kMDItemContentCreationDate | Creation date |
| kMDItemPixelWidth | Image width |
| kMDItemPixelHeight | Image height |
| kMDItemGPSLatitude | GPS latitude |
| kMDItemGPSLongitude | GPS longitude |
| kMDItemMake | Camera make |
| kMDItemModel | Camera model |
Examples
CODEBLOCK4
Requirements
- - macOS (uses Spotlight/mdfind)
- fd (optional, for faster filename search): INLINECODE8
- exiftool (optional, for advanced metadata): INLINECODE9
技能名称: local-image-search
详细描述:
本地图片搜索
使用macOS Spotlight或fd快速搜索本地图片。
快速入门
按名称搜索
bash
使用fd(最快)
fd -e jpg -e png -e jpeg -e heic -e webp -e gif -e tiff 模式 /搜索路径
使用Spotlight
mdfind -onlyin /搜索路径 kMDItemDisplayName ==
模式
按日期搜索
bash
今天
mdfind -onlyin ~/图片 kMDItemContentTypeTree == public.image && kMDItemFSContentChangeDate > $time.today()
最近7天
mdfind -onlyin ~/图片 kMDItemContentTypeTree == public.image && kMDItemFSContentChangeDate > $time.now(-604800)
本月
mdfind -onlyin ~/图片 kMDItemContentTypeTree == public.image && kMDItemFSContentChangeDate > $time.this_month()
按位置搜索(GPS)
bash
有GPS坐标
mdfind kMDItemContentTypeTree == public.image && kMDItemGPSStatus == GPS
在特定区域(近似)
mdfind kMDItemContentTypeTree == public.image && kMDItemGPSLatitude > 39 && kMDItemGPSLatitude < 41
列出所有图片
bash
主目录中的所有图片
mdfind kMDItemContentTypeTree == public.image
仅特定目录
mdfind -onlyin ~/图片 kMDItemContentTypeTree == public.image
仅特定类型
mdfind -onlyin ~/图片 kMDItemContentType == public.png
可用脚本
基础搜索
- - scripts/searchbyname.sh - 按文件名模式搜索图片
- scripts/searchbydate.sh - 按创建/修改日期搜索
- scripts/list_all.sh - 列出目录中的所有图片
高级搜索
- - scripts/searchbylocation.sh - 按GPS坐标搜索
- scripts/searchbysize.sh - 按图片尺寸搜索
- scripts/search_similar.sh - 查找视觉相似图片(需要感知哈希)
实用工具
- - scripts/thumbnail.sh - 为结果生成缩略图
- scripts/copy_results.sh - 将搜索结果复制到目标位置
支持的图片类型
PNG图片 |
| heic | iPhone照片 |
| webp | WebP图片 |
| gif | GIF图片 |
| tiff | TIFF图片 |
| raw | RAW相机文件 |
| dng | 数字负片 |
元数据搜索键
| 键 | 描述 |
|---|
| kMDItemDisplayName | 文件名 |
| kMDItemFSContentChangeDate |
修改日期 |
| kMDItemContentCreationDate | 创建日期 |
| kMDItemPixelWidth | 图片宽度 |
| kMDItemPixelHeight | 图片高度 |
| kMDItemGPSLatitude | GPS纬度 |
| kMDItemGPSLongitude | GPS经度 |
| kMDItemMake | 相机品牌 |
| kMDItemModel | 相机型号 |
示例
bash
查找所有截图
./scripts/search
byname.sh 屏幕截图 ~/桌面
查找今天的照片
./scripts/search
bydate.sh today ~/图片
查找iPhone照片
./scripts/search
byname.sh IMG_ ~/图片
将结果复制到文件夹
./scripts/search
bydate.sh today ~/图片 | ./scripts/copy_results.sh ~/桌面/今日照片
系统要求
- - macOS(使用Spotlight/mdfind)
- fd(可选,用于更快的文件名搜索):brew install fd
- exiftool(可选,用于高级元数据):brew install exiftool