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 ) )