mdimport

Import file hierarchies into the Spotlight metadata datastore.

Syntax
      mdimport [-itpAXLr] [-d level] [-o -outputfile] [ file | directory ... ]

Key
   -i         Request Spotlight to import file or recursively import directory.
              The files will be imported using the normal mechanisms and attributes 
              will be stored in the Spotlight index. This is the implied switch if none are specified.

   -t         Request Spotlight to test import file, sending the result back to mdimport for possible
              further processing. The attributes will not be stored in the Spotlight index.
              This is useful to test Spotlight import plug-ins.

   -d level    Print debugging information. This requires -t.

   -d1        Print summary of test import

   -d2        Print summary of import and all attributes, except kMDItemTextContent

   -d3        Print summary of import and all attributes

   -o outfile   Store attribute into outfile. This requires -t.

   -p         Print out performance information gathered during the run.  This requires -t.

   -A         Print out the list of all of the attributes and their localizations in the current language and exit.

   -X         Print the schema file and exit.

   -L         Print the list of installed importers and exit.

   -r         Ask the server to reimport files for UTIs claimed by the listed plugin.
              For example, the following would cause all of the chat files on the system to be reimported:
                    mdimport -r /System/Library/Spotlight/Chat.mdimporter

mdimport is used to test Spotlight plug-ins, list the installed plug-ins and schema, and re-index files handled by a plug-in when a new
plug-in is installed.

Commonly used attributes:

kMDItemAlternateNames - Alternative display names of the file.
kMDItemApplicationCategories - Application Categories a member of categories.
kMDItemAudiences - Who the document is intended for.
kMDItemAuthors - Authors of this item.
kMDItemCity - Town/City.
kMDItemComment - Comment.
kMDItemCopyright - Copyright.
kMDItemCountry - Region or location where the item was created according to the provider.
kMDItemCreator - Application used to create the document.
kMDItemDateAdded - Date when this item was last moved.
kMDItemDescription - Description.
kMDItemDisplayName - Localised name of the file.
kMDItemEditors - Editors of this item.
kMDItemFSHasCustomIcon - Whether the file has a custom icon.
kMDItemFSInvisible - Whether the file is visible.
kMDItemFSIsExtensionHidden - Whether the file extension is hidden.
kMDItemFSIsReadable - is readable?
kMDItemFSIsStationery - Whether the file is stationery.
kMDItemFSIsWriteable - is writable?
kMDItemFSLabel - Finder label assigned to the file.
kMDItemFSName - Filename.
kMDItemFinderComment - Spotlight comment.
kMDItemIsQuarantined - is quarantined?
kMDItemLastUsedDate - Date when this item was last opened.
kMDItemNamedLocation - Name of the location or point of interest.
kMDItemPath - Complete pathname of this file.
kMDItemPhysicalSize - Physical size of the item in bytes.
kMDItemTitle - Title of this item.
kMDItemVersion - Version number of this item.
kMDItemWhereFroms - Where the item came from.

Examples

List all attributes:

$ mdimport -A

Request Spotlight to test animport file:

$ mdimport -t testfile

“The real voyage of discovery consists not in seeking new landscapes but in having new eyes” ~ Marcel Proust

Related macOS commands

Spotlight Metadata Attributes - List of all the kDM* attributes (or just use mdls -A to list the attributes of a file).
mdfind - Spotlight search.
mdutil - Manage Spotlight metadata store.
find - Search for files that meet a desired criteria.
apple.stackexchange.com - Program to update the kMDItemDateAdded of a file with its "Date Modified" [zip].


 
Copyright © 1999-2024 SS64.com
Some rights reserved