Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 464
AP. Avatar asked Dec 16 '11 06:12

AP.


People also ask

How do I add metadata to a file on a Mac?

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.

How do I add custom metadata to a file?

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.

How do you use color tags on a Mac?

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.


2 Answers

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.

like image 186
Lri Avatar answered Sep 21 '22 02:09

Lri


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.

like image 36
Ned Deily Avatar answered Sep 22 '22 02:09

Ned Deily