I am looking for a command line utility (I need to use it in a script) that can set Spotlight metadata to files.
|
I don't think there's a way to -- the Spotlight indexes are generated by metadata importers that scan files and figure out their properties. If the relevant importer doesn't detect some property, then as far as Spotlight is concerned it doesn't exist. Now, it might be possible to change the actual file in such a way as to add properties to its index entry. This page claims you can add extended attributes starting with "com.apple.metadata:" and they'll be added to the spotlight entry for the file, but I couldn't get it to work. The SpotMeta project extends the import system to add extended attributes to the spotlight database, but only works on OS X v10.4. Not an actual solution, but that's as close as I could find... |
|||||
|
|
You can always use the command line tool That's what spotlight uses to build it's index. Note that spotlight information keys are prefixed with As quick example, to change the display name on spotlight of a file:
to access xattr help, type on t:
|
|||
|
|
|
If you have installed Apple Developer Tools (usually appears under /Developer/Tools), then you have access to the SetFile and GetFileInfo commands which both assist in manipulating metadata of files. Additionally, I found a set of command line utilities called osxutils that may prove useful with additional requirements that come up while writing your scripts. |
|||||||
|