dos下删除指定目录中的除指定文件格式之外的所有文件bat批处理文件,包括子目录

@echo off
::删除除.c,.h,.s,.asm之外的所有文件
for /f "delims=" %%i in ('dir E:\iTOP4418\linux /a-d /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"
)
)
)
)
)
)
::删除空目录
for /f"delims="%%j in('dir E:\iTOP4418\linux /ad /s /b')do rd "%%~sj"


exit

猜你喜欢

转载自blog.csdn.net/august_edward/article/details/79973401