我有机会做了一些实验
mdfind
首先,我们来看一个名为
tardis.png
那是挂在我的Mac电脑上的。
mdls tardis.png
输出
_kMDItemOwnerUserID = 501
kMDItemBitsPerSample = 32
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2017-05-31 14:15:03 +0000
kMDItemContentModificationDate = 2017-05-31 14:15:03 +0000
kMDItemContentType = "public.png"
kMDItemContentTypeTree = (
"public.png",
"public.item",
"public.png",
"public.data",
"public.image",
"public.content"
)
kMDItemCreator = "Adobe Photoshop CC 2017 (Macintosh)"
kMDItemDateAdded = 2017-05-31 14:15:23 +0000
kMDItemDisplayName = "tardis.png"
kMDItemFSContentChangeDate = 2017-05-31 14:15:23 +0000
kMDItemFSCreationDate = 2017-05-31 14:15:22 +0000
kMDItemFSCreatorCode = "8BIM"
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "tardis.png"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 1488497
kMDItemFSTypeCode = "PNGf"
kMDItemHasAlphaChannel = 0
kMDItemKind = "Portable Network Graphics image"
kMDItemLogicalSize = 1488497
kMDItemOrientation = 1
kMDItemPhysicalSize = 1490944
kMDItemPixelCount = 2091600
kMDItemPixelHeight = 1494
kMDItemPixelWidth = 1400
kMDItemProfileName = "sRGB IEC61966-2.1"
kMDItemResolutionHeightDPI = 72
kMDItemResolutionWidthDPI = 72
下面是一个匹配并列出该文件的查询:
mdfind -onlyin . "(kMDItemPixelHeight>1500 || kMDItemPixelWidth=1400)&& kMDItemKind='*image*' && kMDItemProfileName='srgb*'c"
&&
(和)和
||
(或),如何在括号内分组条件
(conditionA || conditionB)
以及如何进行不区分大小写的搜索(通过附加
c
在搜索字符串之后)。
示例
列出我在Mac上拍摄照片时使用的所有摄像头和扫描仪:
mdfind -0 kind:image | xargs -0 mdls -n kMDItemAcquisitionModel | sort -u
kMDItemAcquisitionModel = "645 PRO Mk III for iOS"
kMDItemAcquisitionModel = "BlackBerry 8900"
kMDItemAcquisitionModel = "BlackBerry 9000"
kMDItemAcquisitionModel = "Canon EOS 5D Mark III"
kMDItemAcquisitionModel = "Canon EOS 5D"
kMDItemAcquisitionModel = "Canon EOS 7D Mark II"
kMDItemAcquisitionModel = "Canon EOS 7D"
kMDItemAcquisitionModel = "Canon EOS-1D Mark II N"
kMDItemAcquisitionModel = "Canon EOS-1D Mark IV"
kMDItemAcquisitionModel = "Canon EOS-1D X"
kMDItemAcquisitionModel = "Canon EOS-1DS"
kMDItemAcquisitionModel = "Canon EOS-1Ds Mark II"
kMDItemAcquisitionModel = "Canon EOS-1Ds Mark III"
kMDItemAcquisitionModel = "EOS-1Ds Mark III"
kMDItemAcquisitionModel = "EPSON Perfection 4990"
kMDItemAcquisitionModel = "NIKON D800"
kMDItemAcquisitionModel = "NIKON D800E"
kMDItemAcquisitionModel = "Perfection 4990"
kMDItemAcquisitionModel = "Perfection4990"
kMDItemAcquisitionModel = "PerfectionV700 "
kMDItemAcquisitionModel = "PerfectionV700"
kMDItemAcquisitionModel = "TANGO "
kMDItemAcquisitionModel = "TANGO"
kMDItemAcquisitionModel = "iPad mini 4"
kMDItemAcquisitionModel = "iPad mini"
kMDItemAcquisitionModel = "iPad"
kMDItemAcquisitionModel = "iPhone 3G"
kMDItemAcquisitionModel = "iPhone 3GS"
kMDItemAcquisitionModel = "iPhone 4"
kMDItemAcquisitionModel = "iPhone 4S"
kMDItemAcquisitionModel = "iPhone 5"
kMDItemAcquisitionModel = "iPhone 5s"
kMDItemAcquisitionModel = "iPhone 6"
kMDItemAcquisitionModel = "iPhone 6s"
kMDItemAcquisitionModel = "iPhone SE"
kMDItemAcquisitionModel = "iPhone"
查找在iPhone 6上拍摄的所有照片:
mdfind "kMDItemAcquisitionModel='*iPhone*6*'"
笔记
-
手册页上说
-onlyin
将搜索范围限制为指定目录。这实际上并不正确,因为它也递归到包含的目录中。
-
你用单打似乎没有什么区别(
=
==
)比较中的等号。
-
文件上说你可以使用
string==[c]"pattern"