Remove all Mac generated files '._' with bash
I'm trying to find the command to delete recursively all Apple Mac generated files such as '._' from the drive. So far I have:
find . -name '._*' -exec rm -rf {} \;
however it doesn't seem to do the trick.
There's now a better way!
See man dot_clean
since OS X 10.5.
dot_clean -n .
will not just delete the dot underbar files in and below the current directory, it'll merge their information into the parent file if it's not already there (and I infer that you want -n
to also delete the dot underbar file if there is no matching native file).
Using the dot as first argument starts in the directory you are currently in.
If you want to find all files beginning with ._ you should use the slash as first parameter so that find starts at the root-directory.
And as some of these files will not be owned by you you might like to use the suso command also.
So the complete command looks like this:
sudo find / -name "._*" -exec rm -rf {} \;
At least for me that always does the trick. Ommiting the -exec part will simply list all files so you might run this first to see whether all files are found you expect
I know: this post is obsolete. Anyway I write here because is the first I found! I had the same problem with a Dropbox account that I used on mac osx, moved now on Windows / Linux Ubuntu. Using bash (mine is the Cygwin64 bash), I typed inside my Dropbox folder:
find . -regex '.+/\._.+' -exec rm {} \;
Note that -rf was removed from above solutions. '._' are supposed to be only files, so do not add too many powers to rm command! ;)