Reputation: 29
set path="D:\Work,D:\workin,D:\files"
set files ="txt,html,xml"
How to search for files with an extension defined in files
in the directories defined in path
and write their names into a file?
Here is what I have tried already:
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 /a-d /b *.txt *.html') do (
echo %%j& >nul 2>&1 copy/y "%%j" ..
)
popd
)
)
popd
Upvotes: 1
Views: 90
Reputation: 14290
You should be able to simplify this process by using a standard FOR
command.
@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
)
)
Upvotes: 1