Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Introduction

Here's my problem. On occasion, I create the odd deb package using dpkg-deb (e.g., dpkg-deb --build "folder" file.deb). The problem is that any file with an extended attribute, carries along an ._AppleDouble file to the package. So when the user installs the bit of software, their system is littered with ._AppleDouble files.

For example,

-rw-r--r--@  1 cksum  staff      18305  9 Sep 22:42 ScreenShot.png

would carry with it a ._ScreenShot.png file.

Current Method of Coping

Currently, I'm using the incredibly agonizing xattr command to list the extended attribute and then strip them. For example, the above would be carrying the following as shown by xattr,

com.apple.FinderInfo
com.apple.metadata:kMDItemIsScreenCapture
com.apple.metadata:kMDItemScreenCaptureType

In this case, I would have to strip the resources one at a time, again using xattr,

xattr -d com.apple.FinderInfo ScreenShot.png
xattr -d com.apple.metadata:kMDItemIsScreenCapture ScreenShot.png
xattr -d com.apple.metadata:kMDItemScreenCaptureType ScreenShot.png

This is quite arduous when you sometimes have dozens of files and has become far too much of a pain.

I'm aware of the utility BlueHarvest, but I'm not keen on paying for something I won't use all that much. Additionally, I've trialed the software and have noticed that unfortunately, it sometimes fails to remove them all. Lastly, it is more suited for the management of disks used by different operating systems than it is for local folders.

Ideal Solution

An ideal solution would be to continue using xattr (as it is the most reliable) but having the process automated. It is important that I remove the ._AppleDouble files before I package them. This, however, is not the only solution and I am certainly open to all manner of ideas. But I am hoping that I can accomplish my goal without the need to install additional programs or rely on daemons.

share|improve this question
    
Use makefiles? Perhaps putting find . -type f -name ._.\* -delete in some target could help. IIRC OS X's find has -delete. if it doesn't you can do the good 'ole fashioned -exec rm -fv {} \;. –  Jason Salaz Sep 21 '11 at 23:24
    
@VxJasonxV That would work but only on the target system. I'd like to remove the AppleDouble files before I package them (I'll make that clearer in my question). Thanks for the suggestion. –  cksum Sep 21 '11 at 23:34
    
@VxJasonxV - FYI find on OS X supports -delete (at least with 10.5, 10.6, 10.7, not certain about earlier versions.) –  Slomojo Sep 22 '11 at 0:12
    
My point was to run the cleanup before you package the files. –  Jason Salaz Sep 22 '11 at 0:30
    
@VxJasonxV I tried that, didn't work. I suspect the extended attributed work differently. I've read about removing resource forks with some suggesting the same procedure, but I don't think AppleDouble files are the same thing. But thank you :) –  cksum Sep 22 '11 at 6:27
show 3 more comments

2 Answers

up vote 7 down vote accepted

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.

share|improve this answer
    
Nice, I didn't know about that one. Thanks! –  l'L'l Sep 22 '11 at 0:00
    
There is no -c flag in OSX 10.6.8, but dot_clean does work –  JasonPlutext Mar 3 '13 at 0:49
add comment

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

share|improve this answer
    
Thanks ioi. I've tried dot_clean before and it never worked for me. I suspect extended attributes are different. In any case, I did find the solution :) –  cksum Sep 22 '11 at 2:30
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.