Skip to content

Instantly share code, notes, and snippets.

@magnusdahlstrand
Created February 27, 2012 13:58
Show Gist options
  • Select an option

  • Save magnusdahlstrand/1923948 to your computer and use it in GitHub Desktop.

Select an option

Save magnusdahlstrand/1923948 to your computer and use it in GitHub Desktop.
Remove all ._* and .AppleDouble-files
Remove ._*- and .AppleDouble-files from folders.
Adapted from Torkel's comment on http://hints.macworld.com/article.php?story=20021118060850652
Cred to hiber for suggesting adding -print0/-0 to solve whitespace issue.
See all ._*-files:
find . -name '._*' | more
Remove all ._*-files:
find . -name '._*' -print0 | xargs -0 rm
See all .AppleDouble-files:
find . -name '.AppleDouble' | more
Remove all .AppleDouble-files:
find . -name '.AppleDouble' -print0 | xargs -0 rm -rf
Remove all Thumbs.db-files:
find . -name 'Thumbs.db' -print0 | xargs -0 rm
@hiber
Copy link

hiber commented Jul 11, 2012

deal with spaces in path

find . -name '._*' -print0 | xargs -0 rm
find . -name '.DS_Store' -print0 | xargs -0 rm

@magnusdahlstrand
Copy link
Author

Nice one! Thanks :)

@NicolasGoeddel
Copy link

Just use double quotes. Then you don't need xargs:

find . -name '._*' -exec rm "{}" \;
find . -name '.DS_Store' -exec rm "{}" \;

@dwn64
Copy link

dwn64 commented Mar 7, 2026

you can also delete files directly with find using the -delete flag:

find . -name '._*' -delete
find . -name '.DS_Store' -delete
find . -name 'Thumbs.db' -delete

this has the benefit of handling the entire operation using just find (without spawning any child processes), and should be the most performant method in this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment