Code: Select all
def rmtree(d): # Remove file or tree
try:
if os.stat(d)[0] == 16384: # Dir
for f in os.ilistdir(d):
rmtree("/".join((d, f[0]))) # File or Dir
os.rmdir(d)
else: # File
os.remove(d)
except:
print("rm of '%s' failed" % d)