Mac OS X : add a custom meta data field to any file

前端 未结 5 1773
有刺的猬
有刺的猬 2021-01-30 18:30

I would like to me able to set (and get) a custom metadata attribute for any file.

What is the best way to do this?

Thanks

5条回答
  •  既然无缘
    2021-01-30 18:49

    Custom attribute names work for me:

    $ xattr -w com.apple.metadata:MyAttribute gfdylvyieo a.txt
    $ mdls -n MyAttribute a.txt
    MyAttribute = "gfdylvyieo"
    $ mdfind gfdylvyieo
    /private/tmp/a.txt
    $ mdfind 'MyAttribute=*'
    /private/tmp/a.txt
    

    xattr -wx is not needed if the value is plain text:

    xattr -w com.apple.metadata:kMDItemFinderComment aa file.txt
    

    When you add a Spotlight comment from Finder, it is stored both as an extended attribute and in a .DS_Store file. If you just add an extended attribute, the Spotlight comment field appears blank in Finder, but the comment metadata is still indexed by Spotlight.

提交回复
热议问题