如何在多个目录中search具有给定扩展名的文件?

set path="D:\Work,D:\workin,D:\files" set files ="txt,html,xml" 

如何search在path定义的目录的files中定义的扩展名的files ,并将其名称写入文件?

这是我已经尝试过的:

 set "list=list.txt" pause pushd "%~dp0" >"%list%" ( for /f "delims=" %%i in ('2^>nul dir /ad /b') do ( pushd "%%i" for /f "delims=" %%j in ('2^>nul dir /ad /b *.txt *.html') do ( echo %%j& >nul 2>&1 copy/y "%%j" .. ) popd ) ) popd 

您应该能够通过使用标准的FOR命令来简化这个过程。

 @Echo off >"FileList.log" ( for %%G in (D:\Work,D:\workin,D:\files) do ( pushd "%%~G" for %%H in (*.xml *.txt *.html) do ( echo %%~H copy /y "%%~H" .. ) popd ) )