import shutil for root,subdirs, files in os.walk(path): subdirs[:] = [d for d in subdirs if '.' not in d] for subdir in subdirs: print(os.path.join(path,subdir)) shutil.rmtree(os.path.join(path,subdir))
Happy learning.