How to edit the metadata information displayed by mdls from CLI?

The Spotlight metadata attributes are not stored in the files, but they are based on other metadata values or properties of the files.

  • ID3 tags can be edited from iTunes or with for example mid3v2 from mutagen
  • Modification times and creation times can be changed with touch or SetFileInfo
  • File flags like kMDItemFSIsExtensionHidden can be edited with chflags
  • kMDItemContentTypeTree depends on the filename extension
  • kMDItemLogicalSize depends on the size of the file

Changes to files are usually reflected in mdls output within a few seconds, but if they are not, try using mdimport.