mdimport, mdutil, mdcheckschema, mdls
mdfind -- finds files matching a metadata query
mdfind [-live] [-count] [-onlyin directory] query
Consults the central metadata store and returns a list of files that match the metadata query.
The query can be a string or a query expression.
-live |
image : mdfind image
mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'"Files with any metadata attribute value matching
skateboard.
Continues to run after gathering the initial results, providing a count of the number of files that
match the query.
mdfind -live skateboard
open all the files in Preview :
$ mdfind -onlyin /Users/shared/books "kiss kate" | xargs openMake the search term more selective, use grep and regular expressions.
$ cat file1.txt Kiss me $ cat file3.txt Kiss me, kate $ mdfind -onlyin /Users/saruman/splotlight-test "kiss me," /Users/saruman/splotlight-test/file1.txt /Users/saruman/splotlight-test/file3.txtThe comma is ignored by spotlight. Using grep:
$ mdfind -onlyin /Users/saruman/splotlight-test "kiss me," | xargs grep -i "Kiss me," /Users/saruman/splotlight-test/file3.txt:Kiss me, kate grep: /Users/saruman/splotlight-test/file: No such file or directory grep: 4.txt: No such file or directory $Use
grep to make the search term case sensitive.
The command failed on the filename file 4.txt because it contains a space. mdfind and xargs .
$ mdfind -0 -onlyin /Users/saruman/splotlight-test "kiss me," | xargs -0 grep -i "Kiss me," /Users/saruman/splotlight-test/file3.txt:Kiss me, kate /Users/saruman/splotlight-test/file 4.txt:Kiss me, kate
|
mdfind, mdutil, mdcheckschema, mdls mdimport -- import file hierarchies into the metadata datastore.
|
mdfind, mdimport, mdcheckschema, mdls
mdutil -- manage the metadata stores used by Spotlight
mdutil [-pEsavd] [-i on | off] volumei ...
-i on | off | Sets the indexing status for volumes . may be delayed due to low disk space or other conditions. | ||||||||||||
-E |
mdfind, mdimport, mdutil, mdls
mdcheckschema schema.xml [...]
The mdcheckschema command validates the mdimporter schema files provided as arguments and indicates whether the schema could be successfully parsed.
mdfind, mdimport, mdutil, mdcheckschema
mdls -- lists the metadata attributes for the specified file
mdls [-name attributeName] [-raw [-nullMarker markerString]] file ...
outputs the values of all the metadata attributes associated with files
-name attributeName |
> mdls 0installScreen-090502
kMDItemContentCreationDate = 2009-05-03 10:16:14 -0400
kMDItemContentModificationDate = 2009-05-03 10:16:14 -0400
kMDItemContentType = "public.data"
kMDItemContentTypeTree = (
"public.data",
"public.item"
)
kMDItemDisplayName = "0installScreen-090502"
kMDItemFSContentChangeDate = 2009-05-03 10:16:14 -0400
kMDItemFSCreationDate = 2009-05-03 10:16:14 -0400
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "0installScreen-090502"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 80
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 185107
kMDItemFSTypeCode = ""
kMDItemKind = "Plain text"
kMDItemLastUsedDate = 2009-05-03 10:16:14 -0400
kMDItemUsedDates = ( 2009-05-03 00:00:00 -0400)
|
mdls hereWeGo.aiff
kMDItemAudioBitRate = 352800
kMDItemAudioChannelCount = 1
kMDItemAudioSampleRate = 22050
kMDItemBitsPerSample = 16
kMDItemContentCreationDate = 2015-01-08 22:31:31 +0000
kMDItemContentModificationDate = 2015-01-08 22:31:34 +0000
kMDItemContentType = "public.aifc-audio"
kMDItemContentTypeTree = (
"public.aifc-audio",
"public.audio",
"public.audiovisual-content",
"public.data",
"public.item",
"public.content"
)
kMDItemDateAdded = 2015-01-08 22:31:31 +0000
kMDItemDisplayName = "hereWeGo.aiff"
kMDItemDurationSeconds = 0.884172335600907
kMDItemFSContentChangeDate = 2015-01-08 22:31:34 +0000
kMDItemFSCreationDate = 2015-01-08 22:31:31 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "hereWeGo.aiff"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 43088
kMDItemFSTypeCode = ""
kMDItemKind = "AIFF-C audio"
kMDItemLogicalSize = 43088
kMDItemMediaTypes = (
Sound
)
kMDItemPhysicalSize = 45056
kMDItemTotalBitRate = 352800
|
mdls /Volumes/DATA/dgerman/CreditCardF.jpg
kMDItemAcquisitionMake = "Canon"
kMDItemAcquisitionModel = "CanoScan 5600F"
kMDItemBitsPerSample = 32
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2013-08-30 16:35:08 +0000
kMDItemContentModificationDate = 2013-08-30 16:35:08 +0000
kMDItemContentType = "public.jpeg"
kMDItemContentTypeTree = (
"public.jpeg",
"public.image",
"public.data",
"public.item",
"public.content"
)
kMDItemCreator = "MP Navigator EX 2.0"
kMDItemDateAdded = 2014-08-22 01:36:06 +0000
kMDItemDisplayName = "CreditCardF.jpg"
kMDItemEXIFVersion = "2.2.1"
kMDItemFSContentChangeDate = 2013-08-30 16:35:08 +0000
kMDItemFSCreationDate = 2013-08-30 16:35:08 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "CreditCardF.jpg"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 1250728
kMDItemFSTypeCode = ""
kMDItemHasAlphaChannel = 0
kMDItemKind = "JPEG image"
kMDItemLogicalSize = 1250728
kMDItemOrientation = 0
kMDItemPhysicalSize = 1253376
kMDItemPixelCount = 4436545
kMDItemPixelHeight = 1945
kMDItemPixelWidth = 2281
kMDItemProfileName = "sRGB IEC61966-2.1"
kMDItemResolutionHeightDPI = 600
kMDItemResolutionWidthDPI = 600
kMDItemWhiteBalance = 0
|
ContentTreeType
public
.data, .item, .folder, .directory, .content .text, .plain-text, .html, .executable
.unix-executable, .composite-content, .source-code, .shell-script, .script, .content,
.perl-script, .log
com.microsoft.word.doc,
com.adobe.pdf,
com.netscape.javascript-source,
com.microsoft.excel.xls,
com.apple.log,
com.apple.finder.burn-folder,
/System/Library/LaunchDaemons/com.apple.metadata.com.apple.metadata.mds.scan.plist
<key>Label <string>com.apple.metadata.mds.scan
<key>ProgramArguments
<string>/System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker
<string>-s <string>mdworker-scan
<string>-c <string>MDSSyncScanWorker
<string>-m <string>com.apple.metadata.mds.scan
<key>MachServices <key>com.apple.metadata.mds.scan <key>ResetAtClose <true>
<key>POSIXSpawnType <string>Interactive
<key>CFBundleIdentifier <string>com.apple.Spotlight
<key>LowPriorityBackgroundIO <false>
<key>Label <string>com.apple.metadata.mds
<key>ProgramArguments <string>/System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Support/mds
<key>MachServices
<dict>
<key>com.apple.metadata.mds <true>
<key>com.apple.metadata.mds.legacy <true>
<key>com.apple.metadata.mds.xpcs <true>
<key>com.apple.metadata.mds.cachedelete <true>
</dict>
<key>POSIXSpawnType <string>Interactive
<key>KeepAlive <true>
<key>SoftResourceLimits
< <key>NumberOfFiles 2048 <
<key>HardResourceLimits < <key>NumberOfFiles 2048 <
<key>CFBundleIdentifier <string>com.apple.Spotlight
<key>LowPriorityBackgroundIO <false>
<key>EnvironmentVariables <
/System/Library/LaunchDaemons/com.apple.metadata.mds.index.plist
<key>Label <string>com.apple.metadata.mds.index
<key>ProgramArguments
<string>/System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mds_stores
<key>MachServices
<key>com.apple.metadata.mds.index <true>
<key>com.apple.metadata.mds.index.xpc <true>
<key>SoftResourceLimits <key>NumberOfFiles 2048
<key>HardResourceLimits <key>NumberOfFiles 2048
<key>LowPriorityBackgroundIO <true>
<key>CFBundleIdentifier <string>com.apple.Spotlight
<key>POSIXSpawnType <string>Interactive
<key>EnableTransactions <true>
<key>EnvironmentVariables <dict/>
apple.spotlight.IndexAgent
apple.Spotlight
/System/Library/LaunchDaemons/com.apple.diagnosticextensions.osx.spotlight.helper.plist
<key>Label <string>com.apple.diagnosticextensions.osx.spotlight.helper
<key>Program(sic)?Arguments? <string>/System/Library/PrivateFrameworks/DiagnosticExtensions.framework/PlugIns/osx-spotlight.appex/Contents/XPCServices/spotlighthelper
<key>MachServices <key>com.apple.diagnosticextensions.osx.spotlight.helper <true>
<key>EnableTransactions <true>
<key>EnablePressuredExit <true>
<key>RunAtLoad <false>
<key>POSIXSpawnType <string>Adaptive
>launchctl list |grep 'md' |cut -f3-4 -d '.'|sortc
/usr/bin/sort --ignore-leading-blanks --ignore-case | uniq -c | sort -n |more
1 metadata.mdbulkimport
1 metadata.mdflagwriter
1 metadata.mdwrite
1 mdmclient.agent
1 mdworker.bundles
1 mdworker.isolation
1 mdworker.sizing
3 mdworker.32bit
3 mdworker.lsb
5 mdworker.mail
5 mdworker.shared
9 mdworker.single
mds[64]: (DiskStore.Error:235) Unable to create/find index location 974713FF-7724-4479-9EF1-48A552026443 0