1

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?

John Militer
  • 773
  • 4
  • 14
  • 29
Adrian
  • 19
  • 1
  • I get the same result as you with `Get Info`, but `mdls` and `xattr` still show the comment. – Barmar Jul 06 '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 http://superuser.com/questions/82106/where-does-spotlight-store-its-metadata-index – Barmar Jul 06 '16 at 18:10
  • I only get the `(null)` if I do `Get Info` and then click on the comment field. – Barmar Jul 06 '16 at 18:11

0 Answers0