当然可以,比如以下代码
遍历所有磁盘,按照给出的文本文档test.txt里列出的文件名及扩展名进行查找并将其删除
@echo off
echo 正在搜索文件……
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if exist %%a:\ (
for /f "delims=" %%i in (test.txt) do (
for /f "delims=" %%b in ('dir /a-d /s /b "%%a:\*%%i" 2^>nul') do (
if /i "%%~nxb" equ "%%i" (
echo 发现文件%%~nxb并将其删除……
rem echo "%%~dpb%%~nxb">>temp.txt
del "%%~dpb%%~nxb" /s /f /q
)
)
)
)
)
del test.txt /s /f /q>nul
rem del temp.txt /s /f /q>nul
pause