How to clean ._AppleDouble files from unix packages?

Solution 1:

I need to learn proper xattr usage.

Apparently, xattr has a "clear" (-c) command that can be applied using a wildcard (*), as follows,

xattr -cr *

This results in a recursive removal of all ._AppleDouble files from the current folder on down (the -r flag does recursive, while the -c flag clears them), thus making the process a trivial one line command.

This does not however clear out the .DS_Store files. For that, you can employ the good old "find" command:

find . -type f -name .DS_Store -delete

This will find and delete any .DS_Store files from the current directory on down (recursively).

Lastly, we can bring it all together in the form of an alias that is called upon by simply typing "xat" (put the following in your .bash_profile):

alias xat='find . -type f -name .DS_Store -delete && xattr -cr *'

Now just run "xat" on any directory and it'll strip those pesky resource forks and remove those irritating .DS_Store files from anything inside of it.

Solution 2:

There are many ways you can do this; Here are a couple that I've used:

dot_clean /path/folder

merges dot-underscore files with their parent files.

http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/dot_clean.1.html

If you want to specifically target the .AppleDouble files you can use:

find / -name ".AppleDouble" -depth -exec rm -Rf {} \;

which will simply find them and delete them.

There are ways you can also setup the process ahead of time for SMB shares, etc. when creating dpkgs. This may or may not apply to you, so I just wanted to mention it also.

http://support.apple.com/kb/HT4017