Skip to main content
2 of 4
edited title
user avatar
user avatar

To copy a file and preserve its comment

Is it possible to copy an individual file and preserve its comment?

Here is what I have tried. Nothing here works for me on macOS 14.3.1 and Zsh zsh 5.9 (x86_64-apple-darwin23.0).

cp file.txt file-copy.txt
cp -a file.txt file-copy.txt
rsync file.txt file-copy.txt
rsync -E file.txt file-copy.txt

The tags (red, orange, etc.) are always preserved, but not the comment.

If you run xattr file-copy.txt, you will see that the com.apple.metadata:kMDItemFinderComment extended attribute itself is preserved, but if you run mdls -name kMDItemFinderComment file-copy.txt you will see that its value is "".

user480875