Let's assume that I want to delete all directories with starting name Windows in C:\Program Files (x86) folder. Here is the batch script to do this.
@ECHO OFF FOR /F "delims=" %%W IN ('dir /d/b "C:\Program Files (x86)\Windows*"') DO ( ECHO "C:\Program Files (x86)\%%W" REM RMDIR /s/q "C:\Program Files (x86)\%%W" )
Note: For safety reason, I commented out the rmdir
command. If you want it to delete folders, remove REM
.