删除指定文件外的所有文件

来源:百度知道 编辑:UC知道 时间:2024/05/18 04:01:42
在文件夹C:\Program Files\Internet Explorer中有iedw.exe IEXPLORE.EXE两个文件,我想删除这两个文件以外的所有exe文件,用批处理怎么做?

@echo off
cd /d C:\Program Files\Internet Explorer
for /f "delims=" %%i in ('dir /b /a *.exe') do (
if not "%%i"=="iedw.exe" (
if not "%%i"=="IEXPLORE.EXE" (
del /a "%%i" /f
)
)
)

选中这两文件后,编辑-反向选择,选中你没有选中的文件