As promised in yesterday’s article about using metadata stored in extended attributes to improve Spotlight local search, here is the first test release of SearchKey, an app to do just that.
This first version is very simple: Open a file/folder by clicking on its Open button. Then fill in the text boxes to add text data to be saved as metadata. When you’re happy, click on the Save button, and your text will be stored in that item’s extended attributes (xattrs).
The xattrs used are:
- Headline is stored in the xattr com.apple.metadata:kMDItemHeadline.
- Description in com.apple.metadata:kMDItemDescription.
- Creator in com.apple.metadata:kMDItemCreator.
- Copyright in com.apple.metadata:kMDItemCopyright.
- Keywords in com.apple.metadata:kMDItemKeywords.
These are the five xattrs which are best-preserved by iCloud Drive, and are used in Spotlight’s search indexes. Adding a word to any of those should ensure that local search finds that file.
The Creator and Copyright xattrs are also of much wider value, in helping you track documents which may be subject to copyright or other rights. These are not normally accessible through the Finder or other user tools apart from xattred, so are unlikely to be tampered with by many users.
This first version edits one item at a time. I am working on the next version, which will also feature a batch mode, useful for adding copyright information, for example, to large numbers of files.
This initial test version is available here: searchkey01a1
and in Downloads above. It should run on El Capitan (not tested yet), Sierra, and High Sierra, and on both HFS+ and APFS format disks. xattrs are also preserved on most other file formats.
There is a significant issue in both xattred and SearchKey with respect to the text entered in their text boxes. When editing a property list in xattred, you must enter valid XML, so a character such as the ampersand has to be given in escaped form as
In this version of SearchKey, the text entered in its text boxes is assumed to be valid XML too, so must use the same escaped forms, even though you may not think that you are writing XML! If you use the ampersand sign on its own, this will trigger a parse error and the xattr will not be written.
I will clarify this in their documents, and the next version of SearchKey will automatically convert to escaped forms.
I am sorry for this confusion.