xattr use

I need guidance on using the xattr command.


The following single line command was issued in a terminal window in the folder containing the files to be operated on:

xattr -w com.apple.metadata:kMDItemFinderComment "<comment text>" DSC*.*


No errors were received.


ls -l@ reports the kMDItemFinderComment attribute is present for all the files. (It did not prior to the xattr command.)


Issuing the command mdls on any of the files and reviewing the comments in the finder does not show the <comment text>.


Executing the xattr command entering the attribute value (string) without the quote symbols or spaces results in the string being reported for the kMDItemFinderComment using mdls in a terminal window, but it fails to show in finder using 'Get Info'.


So I believe I have two pertinent questions:

1) How to write a string with spaces to an attribute value using xattr.

2) What is required when writing an attribute value using xattr such that it is reported by both the mdls command in a terminal window and also by finder using 'Get info'?


Appreciate the help,

Lance

Mac Pro

Posted on Dec 11, 2020 6:53 PM

Reply

Similar questions

1 reply

Dec 11, 2020 7:20 PM in response to Skyros

Entering an attribute string value with spaces can be entered by enclosing the string in both double and single quote symbols, e.g. "'<comment text>'" or "'This comment has spaces.'"


The string value is successfully reported using the mdls command in a terminal window, but is not reported by finder using 'Get Info'.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

xattr use

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.