Created
July 19, 2016 01:02
-
-
Save mattsparks/19a0911999a623a3c302cc29c96b293a to your computer and use it in GitHub Desktop.
Python Script to Delete .DS_Store Files on MacOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running this on Python 3.6 and
i
does not increase. I moved it to outside of the main loop and it worked.