문제

I like to tag files with xattr, e.g. xattr -w user.foo bar myfile.

Is there a way that I can then use Spotlight to search for a given xattr key (or key-value pair)? For example, if I put foo or foo:bar in the Spotlight search bar, I'd like it to return myfile in the result list.

I realize you can do this by writing the com.apple.metadata:_kMDItemUserTags attribute - but this is not very portable, so I'm curious if this can be extended to all xattr tags.

도움이 되었습니까?

해결책

Based on this, yes but you are limited to using com.apple attributes. As for extending Spotlight to any xattrib tags, you could but you will need to develop an importer for Spotlight. There are plenty of metadata tags available, I would pick one to be used as a personal tag.

If committed to searching by custom xattrib, I would give up on Spotlight and use:

find . -xattrname foo
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 apple.stackexchange
scroll top