I am modifying file attributes, however I am modifying them for distribution to non-technical people.

Is there anyway I can write attributes to a file and they actually persist when I move them from location to location? I am transferring them from a python web server on my mac to other people with macs but the attributes are all removed.

e.g. com.apple.launchservices.openWith

I am trying to get a file.command to open with text editor by default when I send it. (as a test of persistence)

  • .command would normally open with Terminal. I get the feeling you'd do better adding an extension - file.command.txt than trying to fight the OS defaults. Even though the openWith looks enticing, the extension will be the first thing the system looks at. I get the feeling too that Gatekeeper is going to prevent what would seem like an arbitrary execution.
    – Tetsujin
    Nov 22, 2021 at 11:24
  • while I appreciate your suggestion, it was just an example of one (of many) attributes that I want to maintain. do you know of a way to persist attributes across devices? it does not have to be a webserver as means or transport it can be, in theory, any protocol
    – TheHidden
    Nov 22, 2021 at 11:32
  • 2
    Put the files into a DMG and share that.
    – nohillside
    Nov 22, 2021 at 11:37
  • @nohillside I will have a good and see if that method will be appropriate thanks for the starting point
    – TheHidden
    Nov 22, 2021 at 11:39
  • Would you like an example of using mdls in my answer?
    – bmike
    Nov 22, 2021 at 13:16

1 Answer 1


Apple stores metadata in the file system and not the file, so the easy path would be to include a file system if you need everything to be perfect.

This is the genesis of the need for disk images and installer packages so that you can exert control over the file once it gets written to the file system if using web browsers or other transfer methods fail to set attributes.

Creating a disk image (dmg file) can be a good place to start with this and based on how technical you wish to get, can be quite fancy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .