@echo off
cd /d "%~dp0"
set "newfolder=汇总"
md "%newfolder%" 2>nul
for /f "delims=" %%a in ('dir /ad/b^|findstr /v "^%newfolder%$"') do set "fd=%%a"
for /f "delims=" %%a in ('dir /ad/b "%fd%"') do (
for /f "delims=" %%b in ('dir /ad/b^|findstr /v "^%newfolder%$"') do (
if exist "%%b\%%a\" (
echo;"%%b\%%a" --^> "%newfolder%\%%a\"
xcopy "%%b\%%a" "%newfolder%\%%a\" /q /s
)
)
)
pause