Skip to content

Instantly share code, notes, and snippets.

@mattsparks
Created July 19, 2016 01:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsparks/19a0911999a623a3c302cc29c96b293a to your computer and use it in GitHub Desktop.
Save mattsparks/19a0911999a623a3c302cc29c96b293a to your computer and use it in GitHub Desktop.
Python Script to Delete .DS_Store Files on MacOS
import glob, os
for root, dirs, files in os.walk('/'):
i = 0
for file in files:
if file.endswith('.DS_Store'):
path = os.path.join(root, file)
print "Deleting: %s" % (path)
if os.remove(path):
print "Unable to delete!"
else:
print "Deleted..."
i += 1
print "Files Deleted: %d" % (i)
@akinuri
Copy link

akinuri commented May 8, 2018

Running this on Python 3.6 and i does not increase. I moved it to outside of the main loop and it worked.

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