import os import shutil import subprocess import re dirPath = ["C:\\Users\\user1\\documents","C:\\users\\user2\\downloads"]#Provide the paths here you want to delete x=0 for i in dirPath: fileList = os.listdir(i) try: os.chmod(dirPath,0644) except: pass for f in fileList: try: if os.path.isfile(os.path.join(i, f)): os.remove(os.path.join(i, f)) elif os.path.isdir(os.path.join(i, f)): shutil.rmtree(os.path.join(i, f)) except: x+=1 if x==0: print "Cleared successfully : "+i else: print "Some error removing Files or Folders : "+i