How to edit "kMDItemXxx" file metadata on macOS? Today I tried to edit the metadata of a picture file. I used mdls to display them, then looked for a command to edit one. But I couldn't find any.
For vanilla metadata, like basic timestamps, touch is good enough. And for these things called &quot;extended attributes&quot; (quarantine, etc.), macOS gives you xattr -d.
But is there a CLI way to edit, say, &quot;kMDItemBitsPerSample&quot; or &quot;kMDItemFSName&quot;, or the key/value pairs used by Spotlight?
The Spotlight system collects a variety of types of metadata about files. Some kinds of metadata are what I'd call &quot;superficial&quot;, and can be easily changed by changing the file properties; but some &quot;deeper&quot; ones depend on the contents of the file, and cannot be changed without significant changes to the file itself.
kMDItemFSName is an example of a &quot;superficial&quot; attribute -- it's just the filename, so renaming the file will change it. kMDItemBitsPerSample, on the other hand, is a property of the data in the file (it's the bit depth of an image or audio file). Changing kMDItemBitsPerSample would involve some sort of recoding of the image or audio file.
Mind you, there are some attributes that are in-between in superficiality. For example, mp3 files include metadata like the album name (kMDItemAlbum) and track number (kMDItemAudioTrackNumber) that are part of the file's contents, but can be edited (by some apps, like the old iTunes) without touching the audio content of the file.