Could you help me, I have the following problem. I have thousands of folders that in turn have several sub-folders, there is specifically a sub-folder that is named "0".
Example:
├ DISCO_1 (CARPETA_Principal)
| ├─ 2014353(SUB-CARPETA)
-(SUB-Carpeta"0") #[Carpeta que se desea borrar]
| ├─ 2014354 (SUB-CARPETA)
-(SUB-Carpeta"0") #[Carpeta que se desea borrar]
| └─ 2014355 (SUB-CARPETA)
-(SUB-Carpeta"0") #[Carpeta que se desea borrar]
This is a folder that does not interest me and what I want is to delete all these sub-folders "0"
I know it's with:
import shutil
shutil.rmtree('C:\\Test\\')
How could I do it?
Since you're using Python 2, you can do something very similar to the answer I gave to the question How to get certain files to be deleted from multiple folders in Python? making use of
os.walk
andfnmatch
.Taking as an example structure:
You can use something like this:
Result: