How can I delete all folders named "xname" within a Disk?

-1

Good morning. I want to delete all the FOLDERS of the same NAME and SUB-FOLDERS of the SAME NAME (Excuse redundancy) of a hard drive of 2 petabytes but obviously there are too many FOLDERS to review.

The name of the folder is "namex". It is in more than 2 million folders also in subfolders and I want to Delete all of them by Batch code.

I imagine it's something like this:

del /s/e "C:\" nombrex

Please, if anyone can help me with this topic.

    
asked by Juan Carlos Villamizar Alvarez 25.05.2018 в 22:22
source

2 answers

0

Here is a way to do it found at SO englisch

for /d /r "C:\carpeta inicial" %d in (nombrex) do @if exist "%d" rd /s/q "%d"
  

But first try with an echo to not erase things that are not

for /d /r "C:\carpeta inicial" %d in (nombrex) do @if exist "%d" echo "%d"

Example:

for /d /r "D:\mnt\web" %d in (node_modules) do @if exist "%d" echo "%d"

link

    
answered by 26.05.2018 в 18:47
-1
  • Alert : You must be very careful because generally the C:\ drive is used by your computer and not by external hard drives.

First it indicates to position you in the directory of the drive (as example E: \) and later it deletes its content, it will ask for confirmation:

cd E:\TEMP
del *.*

But you can have subdirectories and content inside them, so this is the correct way to remove the contents of these directories.

cd E:\TEMP
del *.* /s /f /q

If you want to delete all the content, including files and directories , it's done like this:

   rmdir /s /q E:\TEMP
    
answered by 25.05.2018 в 23:26