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
Right click and Info, or cmd + i when the file is selected in the finder will open an information panel and you can add data at the top that will be referenced in Spotlight.
Click the file to which you want to add metadata. In the file's preview screen, click the metadata icon in the right-hand side-bar. Next to Metadata, click Add, then choose the metadata template you'd like to use.
Step 1: Open Finder and select the file or folder you want to tag. Step 2: Go to File in the menu bar. Step 3: Choose a tag color in the Tags section. Step 4: Like many other tasks on MacOS, there's more than one way to tag an item.
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.
The OpenMeta framework is a de-facto third-party standard for adding metadata to OS X files using extended attributes. It is used by a number of third-party applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With