Disappearing color labels in Mac OS X

Published:

Had a tiny fight with Mac OS X the other day, like I often do. This time it was color labels. You probably know (if you have used Mac OS X at all) that you can color label your files. You simply right-click them in the Finder and select a color label.

This can be quite a handy feature, but not so much when it doesn't work. My problem was that I would give a bunch of files color labels, but then shortly after that the label simply disappeared. I could look at the file in the Finder, it had its label, I'd click on it, and the label disappeared. In fact the color label was already gone, it was just that the Finder is kind of slow to update itself... O' how I miss F5 sometimes...

Anyways, you can check if a file really has a label or not by opening up a Terminal and using the following command on the file in question:

$ mdls -name kMDItemFSLabel somefile.ext

It will give you back a number and if the number is greater than zero it means the file has a label.

But what to do about it?

After some digging I found that it might have to do with some XSan issues or corrupt meta files. Mac OS X spreads these meta-files around wherever it goes and apparently they go corrupt from time to time. A quick and simple way to fix this issue is just to clear them all out and let Finder have fun recreating them. As these files are hidden in the Finder, and Mac OS X is so kind to not give us an easy way of showing hidden files, I once again opened up a Terminal. I then went to the directory with the broken meta-files and ran these two commands:

$ rm ._* $ rm .DS_Store

All the labels should then be gone in Finder if you check the folder again. Now re-label them and they should hopefully stay labeled as well. Hope this can help someone else 🙂

Doing it recursively

The following command will do it for the current working directory and all its sub-directories:

$ find . -name .DS_Store -delete $ find . -name "._*" -delete

Files with no extension

If you have filenames without an extension, like for example Some video instead of Some video.mov, Finder won't know how to open these files anymore after you remove the meta-files. If that should happen I recommend that you add the right extension on the filename and you will have no more problems with that. If you prefer to have it without extension you can also select and right-click the files, select Get Info, and then under the Open with category select the application you want the file to be opened with. But seriously, just giving the files proper extensions to begin with is a lot easier to work with... at least I think so...