用批处理删除D、E盘中的所有文件,除了常用的TXT、word、PPT等后缀的文件

2024-12-16 17:33:05
推荐回答(2个)
回答1:

@echo off
for %%a in (d e) do (
cd /d %%a:\
for /r %%b in (*) do if not %%~xb==.ppt if not %%~xb==.doc del /f /q "%%b"
pause

试试.要开机启动就拖到启动文件夹喽..

回答2:

@echo off
for %%a in (txt doc ppt) do set .%%a=a
for %%a in (d e) do (
cd/d %%a:
for /r . %%i in (*) do if not defined %%~xi del/q/f "%%i"
)
pause