Issue
How can I list all folders of a directory in Python and remove them ?
for root, dirs, files in os.walk(r'/home/m110/public_html/ts/'):
print(root)
print(dirs)
print(files)
i run this code in Centos7 but i just need list folder for delete times
Solution
import os
import shutil
dirs= next(os.walk(r'/home/m110/public_html/ts/'))[1]
for name in dirs:
print name
shutil.rmtree(name)
Answered By - sirmagid Answer Checked By - Dawn Plyler (WPSolving Volunteer)