Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a file M on my Mac (OS X ML 10.8.4) and file P on my PC (Win7). File P was originally a copy of file M but is now slightly updated. File M has some extended attributes.

How can I copy file P onto file M, while preserving the extended attributes on file M?

Generally if I copy-paste P onto M through network share, the extended attributes on M are lost.

I'm looking for a an easily implementable / scalable way. cat P > M is not really an option (not even sure if that works). Could rsync help here?

share|improve this question

If there are still ._ files, you can merge them with dot_clean:

$ ls -A
._test.txt test.txt
$ xattr -l test.txt
$ dot_clean .
$ ls -A
$ xattr -l test.txt utf-8;134217984

You can copy attributes with xattr -wx and -px:

xattr -wx attributename "$(xattr -px attributename source.txt)" target.txt

xattr only prints attribute names if the argument is a single file:

for f; do
  for a in $(xattr "$f"); do
    xattr -wx $a "$(xattr -px $a ~/Documents/Original/"$f")" "$f"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .