Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
test.txt
$ xattr -l test.txt
com.apple.TextEncoding: 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"
  done
done
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.