Skip to content

The Eclectic Light Company

Macs, painting, and more
Main navigation
  • Downloads
  • M1 & M2 Macs
  • Mac Problems
  • Mac articles
  • Art
  • Macs
  • Painting
hoakley August 19, 2019 Macs, Technology, Updates, xattr

How to tag documents with metadata that works in search

I’ve recently pointed out how Spotlight search can miss files whose metadata don’t seem to get incorporated into its indexes properly. It’s a worrying problem, because unless you know what you should find, it’s very hard to see that search results are incomplete.

One solution to this problem is to change the metadata that Spotlight has to rely on. In many cases, it’s recovering these from metadata which are stored within the document data, or the contents of the document itself. In my experience and testing, the metadata which Spotlight is most likely to find are those attached to files as extended attributes (xattrs).

Several types of xattr are specifically intended to contain a document’s metadata, including

  • com.apple.metadata:kMDItemHeadline, intended for the document headline;
  • com.apple.metadata:kMDItemDescription, for the document description;
  • com.apple.metadata:kMDItemCreator, for the name of the document creator, usually its author;
  • com.apple.metadata:kMDItemCopyright, for the copyright notice;
  • com.apple.metadata:kMDItemKeywords, for a list of keywords.

The Finder may show some or all of those in its Get Info dialog, and miraculously those xattrs are preserved even when the document is shared through iCloud Drive.

The difficulty in using them is that macOS doesn’t provide any app which can create, edit or display these xattrs – even though they’re discovered by Spotlight searches. You can work with them using my free xattr utility xattred, but that’s a general-purpose editor and overkill when you just want to create and edit those xattrs.

I have two apps which are designed to do just what you want. SearchKey sets and changes those specific xattrs on individual files and whole folders.

searchkey01

For example, it’s quick and simple to add author and copyright data to all the images stored in a folder, or to strip them when you want to work on a batch.

If you just want to edit those metadata on individual files, then SearchKeyLite is all you need.

searchkey02

Using xattrs like this has significant advantages over changing any metadata which might be stored inside the document’s data. As well as being more likely to be included in Spotlight searches, adding metadata in xattrs leaves the data in the document completely untouched. They will be stripped, though, if the file is copied to a file system which doesn’t preserve the contents of attached xattrs.

searchkey03

I have just updated both SearchKey and SearchKeyLite to version 1.3, which are now fully compatible with Catalina, as well as working fully in macOS from El Capitan to Mojave. These new versions also check their code integrity when they’re opened, include links to their Product Page, and have minor improvements such as saving their window positions and sizes.

SearchKey 1.3 is now available from here: searchkey13
SearchKeyLite 1.3 is now available from here: searchkeylite13
and both are available from Downloads above, and from their Product Page.

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Pinterest
  • Email
  • Print

Like this:

Like Loading...

Related

Posted in Macs, Technology, Updates, xattr and tagged extended attributes, macOS, metadata, search, SearchKey, SearchKeyLite, Spotlight, xattr, xattred. Bookmark the permalink.

5Comments

Add yours
  1. 1
    Hikari on August 20, 2019 at 12:00 pm

    Firstly, I really wanted to thank you for this amazing blog you’ve written and maintained filled with *so much* useful information *and* software! I’m honestly in awe of how much work goes into both your extremely detailed write-ups of various parts of macOS and writing and maintaining all of your Mac software. 😭

    On the topic of this article, I had a somewhat traumatic experience with Spotlight and xattrs a little while ago. My Mac mini was running extremely slowly, so I took a look in Activity Monitor. It showed a Spotlight indexing daemon (the exact name of the process escapes me at the moment) at 100+% CPU usage, so blaming it for my issue, I added my entire home directory to the list of locations Spotlight shouldn’t index in System Preferences. Huge mistake! After doing so, to my absolute horror, I realized that doing a ‘Get Info’ on all my downloaded files from Safari *wasn’t* showing the URL(s) in the ‘Where from’ (com.apple.metadata:kMDItemWhereFroms) extended attribute anymore! I was initially devastated, since knowing the location I downloaded certain files from is *extremely* important to me; in some cases, that metadata was more important than the file itself! To my great relief however, after I removed my home directory from the list of locations Spotlight shouldn’t index, the ‘Where from’ entries magically showed up again in the ‘Get Info’ window for all of my downloaded files.

    On the bright side, that scare made me far more aware how important xattrs are to me. I want to make sure they’re being backed up along with the rest of my data as a first-class citizen, irrespective of the file system they’re transferred to (whether it’s HFS+, APFS, NTFS, FAT32, etc.). The only issue being, I’m not exactly sure where and in what form they’re stored on the drive. Also, I’m slightly confused about what happens to xattrs in the following scenario:

    Say I have an external drive (formatted as HFS+) plugged into my Mac containing files with xattrs. If I now take that external drive and plug it into a different Mac, will all the xattrs still show up (the xattrs are stored somewhere on the external drive), or will they be gone (the xattrs of all files from all connected volumes are only stored somewhere on the boot volume of macOS)?

    [Sidenote: The speed issues on my Mac mini ended up actually being due to a build-up of *way* too much dust inside of it! Luckily, since it was a 2012 model, it was extremely easy to open and clean, and after a quick cleaning, now runs as fast as the day I bought it!]

    LikeLiked by 1 person

    • 2
      hoakley on August 20, 2019 at 1:05 pm

      Thank you.
      Xattrs aren’t stored in the files themselves, but in the file system metadata in HFS+ and APFS. I have an article here which examines their behaviour with different file systems, which you may find helpful.
      By and large, working with HFS+ and APFS, xattrs are preserved and not stripped, although iCloud transfers are different and only retain a small group of xattrs. They’re backed by Time Machine, particularly to a backup drive formatted in HFS+.
      Because they’re kept in the file system metadata, wherever you mount that file system, the xattrs will be accessible just as they were when originally written – they travel with the volume, not the boot disk.
      I hope that reassures you.
      Howard.

      LikeLike

  2. 3
    NotarySojac on August 22, 2019 at 3:32 am

    Are Finder Comments, tags, and labels also extended attributes?

    LikeLiked by 1 person

    • 4
      hoakley on August 22, 2019 at 4:52 am

      Yes: there’s an introduction to xattrs in this article, which has links to more detailed accounts.
      Howard.

      LikeLike

      • 5
        NotarySojac on August 22, 2019 at 5:34 pm

        Thank you!

        LikeLiked by 1 person

·Comments are closed.

Quick Links

  • Downloads
  • Mac Troubleshooting Summary
  • M1 & M2 Macs
  • Mac problem-solving
  • Painting topics
  • Painting
  • Long Reads

Search

Monthly archives

  • August 2022 (45)
  • July 2022 (76)
  • June 2022 (73)
  • May 2022 (76)
  • April 2022 (71)
  • March 2022 (77)
  • February 2022 (68)
  • January 2022 (77)
  • December 2021 (75)
  • November 2021 (72)
  • October 2021 (75)
  • September 2021 (76)
  • August 2021 (75)
  • July 2021 (75)
  • June 2021 (71)
  • May 2021 (80)
  • April 2021 (79)
  • March 2021 (77)
  • February 2021 (75)
  • January 2021 (75)
  • December 2020 (77)
  • November 2020 (84)
  • October 2020 (81)
  • September 2020 (79)
  • August 2020 (103)
  • July 2020 (81)
  • June 2020 (78)
  • May 2020 (78)
  • April 2020 (81)
  • March 2020 (86)
  • February 2020 (77)
  • January 2020 (86)
  • December 2019 (82)
  • November 2019 (74)
  • October 2019 (89)
  • September 2019 (80)
  • August 2019 (91)
  • July 2019 (95)
  • June 2019 (88)
  • May 2019 (91)
  • April 2019 (79)
  • March 2019 (78)
  • February 2019 (71)
  • January 2019 (69)
  • December 2018 (79)
  • November 2018 (71)
  • October 2018 (78)
  • September 2018 (76)
  • August 2018 (78)
  • July 2018 (76)
  • June 2018 (77)
  • May 2018 (71)
  • April 2018 (67)
  • March 2018 (73)
  • February 2018 (67)
  • January 2018 (83)
  • December 2017 (94)
  • November 2017 (73)
  • October 2017 (86)
  • September 2017 (92)
  • August 2017 (69)
  • July 2017 (81)
  • June 2017 (76)
  • May 2017 (90)
  • April 2017 (76)
  • March 2017 (79)
  • February 2017 (65)
  • January 2017 (76)
  • December 2016 (75)
  • November 2016 (68)
  • October 2016 (76)
  • September 2016 (78)
  • August 2016 (70)
  • July 2016 (74)
  • June 2016 (66)
  • May 2016 (71)
  • April 2016 (67)
  • March 2016 (71)
  • February 2016 (68)
  • January 2016 (90)
  • December 2015 (96)
  • November 2015 (103)
  • October 2015 (119)
  • September 2015 (115)
  • August 2015 (117)
  • July 2015 (117)
  • June 2015 (105)
  • May 2015 (111)
  • April 2015 (119)
  • March 2015 (69)
  • February 2015 (54)
  • January 2015 (39)

Tags

Adobe APFS Apple AppleScript Apple silicon backup Big Sur Blake bug Catalina Consolation Console diagnosis Disk Utility Doré El Capitan extended attributes Finder firmware Gatekeeper Gérôme HFS+ High Sierra history history of painting iCloud Impressionism iOS landscape LockRattler log logs M1 Mac Mac history macOS macOS 10.12 macOS 10.13 macOS 10.14 macOS 10.15 macOS 11 macOS 12 malware Metamorphoses Mojave Monet Monterey Moreau MRT myth narrative OS X Ovid painting Pissarro Poussin privacy realism riddle Rubens Sargent scripting security Sierra SilentKnight SSD Swift symbolism Time Machine Turner update upgrade xattr Xcode XProtect

Statistics

  • 12,403,351 hits
Blog at WordPress.com.
Footer navigation
  • About & Contact
  • Macs
  • Painting
  • Language
  • Tech
  • Life
  • General
  • Downloads
  • Mac problem-solving
  • Extended attributes (xattrs)
  • Painting topics
  • Hieronymus Bosch
  • English language
  • LockRattler: 10.12 Sierra
  • LockRattler: 10.13 High Sierra
  • LockRattler: 10.11 El Capitan
  • Updates: El Capitan
  • Updates: Sierra, High Sierra, Mojave, Catalina, Big Sur
  • LockRattler: 10.14 Mojave
  • SilentKnight, silnite, LockRattler, SystHist & Scrub
  • DelightEd & Podofyllin
  • xattred, Metamer, Sandstrip & xattr tools
  • 32-bitCheck & ArchiChect
  • T2M2, Ulbow, Consolation and log utilities
  • Cirrus & Bailiff
  • Taccy, Signet, Precize, Alifix, UTIutility, Sparsity, alisma
  • Revisionist & DeepTools
  • Text Utilities: Nalaprop, Dystextia and others
  • PDF
  • Keychains & Permissions
  • LockRattler: 10.15 Catalina
  • Updates
  • Spundle, Cormorant, Stibium, Dintch, Fintch and cintch
  • Long Reads
  • Mac Troubleshooting Summary
  • LockRattler: 11.0 Big Sur
  • M1 & M2 Macs
  • Mints: a multifunction utility
  • LockRattler: 12.x Monterey
  • VisualLookUpTest
Secondary navigation
  • Search

Post navigation

Footnote: Feet and footwear in paintings 2
Solutions to Saturday Mac riddles 8

Begin typing your search above and press return to search. Press Esc to cancel.

  • Follow Following
    • The Eclectic Light Company
    • Join 6,059 other followers
    • Already have a WordPress.com account? Log in now.
    • The Eclectic Light Company
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • View post in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...
 

    %d bloggers like this: