You can try:
setlocal enabledelayedexpansion
set "dump_path=C:est"
set "dump_path1=!dump_path!xyz"
set "dump_path2=!dump_path!xyz.py"
set "str=!dump_path1! !dump_path2!"
set "max_days=0"
for /f "tokens=* delims=" %%a in ('forfiles -p !dump_path! -m *.* -d -!max_days!^| findstr /v /i "!str!"') do (
set "noext=%%~dpna"
if "!noext!"=="%%a" (call rmdir %%a) else (call del %%a)
)
endlocal
If for some reason, the files/folders you want to skip contain <"spaces">, you must break up the findstr command and search for it/them literally, i.e.:
for /f "tokens=* delims=" %%a in ('forfiles -p !dump_path! -m *.* -d -!max_days!^| findstr /v /i /c:"!dump_path1!"^| findstr /v /i /c:"!dump_path2!"') do (
set "noext=%%~dpna"
if "!noext!"=="%%a" (call rmdir %%a) else (call del %%a)
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…