Can extended attributes be attached to arbitrary files?

You can add custom attributes to whatever file/folder you like (edit: if that recides in a volume with a filesystem with support for extended attributes, of course).

I’ve just tested by adding a “MY_CUSTOM_ATTRIBUTE” (content set to “Hello world”) to a “test” folder. I did it via the addattr command (“add-attribute”), like so:

addattr MY_CUSTOM_ATTRIBUTE "Hello world" test

There are a bunch of attribute related commands:

> ls -1 /bin/*attr
/bin/addattr
/bin/catattr
/bin/copyattr
/bin/listattr
/bin/resattr
/bin/rmattr

Example usage:

> listattr test
File: test
        Type       Size  Name                                
----------------------------------------------------------
 MIME String        31  "BEOS:TYPE"
    Raw Data        24  "_trk/pinfo_le"
        Text        12  "MY_CUSTOM_ATTRIBUTE"

67 bytes total in attributes.
>
>  catattr MY_CUSTOM_ATTRIBUTE test
test : string : Hello world

With respects to showing custom attributes in Tracker… that’s currently more convoluted. I’ll defer to the following explanation by @humdinger, a while ago:

Which attibutes are displayed is stored for each folder in its attribute _trk/columns_le. New folders inherit the settings of their parent.

There’s no easy way to change the displayed attributes for all folders in the system. If you’re familiar with scripting, you could create a script that copies the _trk/columns_le using the command copyattr.

If it’s only a few folders, you can use the “Copy/Paste attributes” from the Attributes menu of the Tracker window.


Others surely will chime in with more info.

Edit: I remember adding colums to Tracker while experimenting with a similar setup to Scott Hacker’s “TrackerBase” (around 20 years ago :frowning: ), but can’t recall how I did it now. (TrackerBase repo on GitHub).

2 Likes