Finder Comments, also known as Spotlight Comments, are such a good idea. Select a file, Get Info in the Finder, and just type your text into the Comments section. You can then find them again in Spotlight searches, and they’re just a Command-I away. This article looks at their use and shortcomings.
Metadata, information about a file rather than the data in that file, should ideally be strongly attached to the file. That’s what happens when the metadata are file attributes (name, date of creation, etc.), or stored in an extended attribute (Finder Tags and a great deal more). Where systems aren’t able to handle extended attributes, or they may become detached, a second best is to tack the metadata onto the file’s data, which is widely practised in cross-platform document types including images, audio, movies, even styled text like RTF.
Where are they kept?
The worst possible place you can store metadata is in a separate file, such as a hidden file of proprietary format located in the same folder. But that’s exactly where Finder Comments are saved. Worse still, as if recognising the error of its ways, Apple duplicated them in an extended attribute (xattr), only that isn’t kept in sync with the other copy. The end result is that Finder Comments are as reliable as loose scraps of paper, and just as easily lost.
When you add or edit your Finder Comment in the Get Info dialog, the Finder saves your text in two different places:
- the primary copy goes into the hidden .DS_Store file in the same folder as the document;
- a secondary copy is saved in a xattr of type
com.apple.metadata:kMDItemFinderComment
for the file.
I refer to them as primary and secondary because the Finder only seems to know about the first. It’s easy to demonstrate that.
Pick a file and give it a distinctive Finder Comment using the Get Info dialog. Using my free metadata editor Metamer, my full editing utility xattred, or the xattr
command in Terminal, inspect that file’s com.apple.metadata:kMDItemFinderComment xattr. You can do that simply in Metamer by opening the file in that app and pasting in com.apple.metadata:kMDItemFinderComment
to the upper of the two boxes, a Combo Box, then pressing the Tab key. Alternatively, take my word for it and just select FinderComment in the popup menu there. The lower box should then display the file’s Finder Comment.
—
Edit that comment in a distinctive way, and click Save. The changed xattr will be written to that file’s xattrs, and can be retrieved whenever you wish. But when you Get Info on that file you’ll see that the comment displayed there hasn’t changed at all. That’s because conversion between the hidden .DS_Store file and the file’s xattr is one-way. There’s no syncing in the other direction.
How well are they preserved?
Move a document with a Finder Comment around using the Finder, and you’ll see that comment is quite well-preserved, even if it remains different from the copy held in that xattr. The moment that anything happens to the .DS_Store file – which, being hidden, you can’t readily see – then your Finder Comment just vanishes. This most commonly happens during transit through cloud storage such as iCloud, or non-Mac file systems. Finder Comments are well-preserved by most compression and archiving apps, though.
How to search them
If you do opt to use Finder Comments, you might be puzzled as to how to find them in Spotlight, which supports two different types of comment. They’re there referred to not as Finder Comments, or just Comments, but Spotlight comments, and you’ll have to add them to your criteria for Find operations before you can get Spotlight to search for contents of these comments. Of course, like the Finder, Spotlight ignores what you might have saved to the com.apple.metadata:kMDItemFinderComment xattr and goes entirely on the information hidden in the .DS_Store file. If that’s gone missing for any reason, then Spotlight can’t find your comment, even though it might be saved in a xattr.
Alternatives
Thankfully, macOS provides a much better way of attaching comments to a file, what it calls simply a Comment. These are displayed in the Get Info dialog in the More Info section rather than the Comments, but can’t be edited there. They’re one of the basic types of metadata supported directly by Metamer, where they appear in the Combo Box menu simply as Comment, of the type com.apple.metadata:kMDItemComment
, and work fine with Spotlight. I’m not sure what’s preventing Apple from phasing out Finder or Spotlight Comments and moving to regular xattr Comments, nor why Finder Comments in .DS_Store files aren’t synced properly with their xattr. I haven’t asked Apple what’s blocking that choice, after all I’m fairly sure that the response would be “No Comment”.
Further reading:
Wikipedia on .DS_Store files
Wim Lewis’s account of the .DS_Store format
Matthew McCullough’s AppleScript tool to sync from xattr to .DS_Store file