I want to keep only one NET folder on drive E. Delete all folders and files except this folder. And don't change the attributes of the NET folder. How to write such a batch script? Thanks for the advice.
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
@echo off
pushd e:\ rem Switch to the root directory of drive E
del /q *.* rem Delete all files in the root directory
for /d %%i in (*) do if /i not "%%i" == "NET" rd /s /q "%%i" rem If the directory is not NET, delete it
popd rem Return to the initial directory
@echo off
pushd e:\
del /q *.*
:start
dir /b e: | findstr /v /i "net" || goto end
call :deldir
goto start
:deldir
wmic fsdir where "drive='e:' and filename!='net'" call delete /NOINTERACTIVE
goto :eof
:end
popd