I have a directory of folders and subfolders that I need to search through to find a certain folder name, "old data", so that I can delete the files within "old data" and delete the folder itself and the files within it (but not it's parent folder). There are 122 folders to search through, with only some of those containing a subfolder named 'old data'. How do I search through each folder for "old data" and delete it? I'm relatively new to python, and the only code I've managed to get is listing the directories so I can visualize which folders have a subfolder named "old data" and which don't:
import os
os.chdir('C:/directory')
for root, dirs, subdirs in os.walk('C:/directory'):
for d in dirs:
print os.path.join(root, d)