Under dos, delete all files in the specified directory except the specified file format bat batch file, including subdirectories

@echo off
:: delete all files except .c, .h, .s, .asm
for /f "delims=" %%i in ('dir E:\iTOP4418\linux /ad /b /s' ) do (
if not %%~xi==.c (
if not %%~xi==.h (
if not %%~xi==.s (
if not %%~xi==.asm (
if not % %~xi==.S (
del /s /a /q "%%~si"
)
)
)
)
)
)
:: delete empty directory
for /f"delims="%%j in('dir E:\iTOP4418 \linux /ad /s /b')do rd "%%~sj"


exit

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324531533&siteId=291194637