Skip to content

Instantly share code, notes, and snippets.

@mathewmariani
Created September 25, 2016 22:52
Show Gist options
  • Save mathewmariani/5051ca876aeaba5feb20bf3db205b794 to your computer and use it in GitHub Desktop.
Save mathewmariani/5051ca876aeaba5feb20bf3db205b794 to your computer and use it in GitHub Desktop.
Useful for removing macOS specific files.
import os
from fnmatch import fnmatch
# pretty useless if youre using git.
root = "./"
search = ["._*", ".DS_Store", ".AppleDouble", ".LSOverride"]
for (path, dirs, files) in os.walk(root):
for name in files:
for exp in search:
if fnmatch(name, exp):
file = os.path.normcase(os.path.join(path, name))
print (file)
os.remove(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment