2

I have a file with a comment as extended attribute. This is how I can see the attribute from the Terminal:
mdls -name kMDItemFinderComment path_to_file
I get the answer
kMDItemFinderComment = "my_comment"

To copy this file to new_location while preserving this comment, I type
cp -p path_to_file new_location
Everything seems to work as typing
mdls -name kMDItemFinderComment new_location
returns
kMDItemFinderComment = "my_comment"

My problem arises when I access the copied file at the new_location from a Finder window. I click on Get Info but the Comments section is empty. After this action, when I try again
mdls -name kMDItemFinderComment new_location
I get
kMDItemFinderComment = (null)

Can anyone help me?

PS: should I use xattr?

  • I get the same result as you with Get Info, but mdls and xattr still show the comment. – Barmar Jul 6 '16 at 18:08
  • It looks like the comments get cached in the folder's .DS_Store file, which isn't updated by cp. See superuser.com/questions/82106/… – Barmar Jul 6 '16 at 18:10
  • I only get the (null) if I do Get Info and then click on the comment field. – Barmar Jul 6 '16 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.