Created
September 18, 2015 09:49
-
-
Save asyndrige/78795d58554fac367da7 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python3 | |
import os | |
import shutil | |
music = os.path.join('/', 'home', 'stan', 'music') | |
def fdeleter(dir): | |
for folder in os.listdir(dir): | |
path = os.path.join(dir, folder) | |
dirs = os.listdir(path) | |
try: | |
if any('.part' in data for data in dirs): | |
shutil.rmtree(path) | |
print(('{0} deleted').format(path, )) | |
elif not dirs: | |
shutil.rmtree(path) | |
print(('{0} deleted').format(path, )) | |
else: | |
fdeleter(path) | |
except: | |
pass | |
if __name__ == "__main__": | |
fdeleter(music) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment