@echo off
for /f "delims=" %%i in ('dir /b /ad "d:\b"') do (md "%%~dpni\a"
copy c:\a "%%~dpni\a")
@echo off
if not exist d:\b md d:\b
copy c:\a d:\b
for /f "tokens=2,3,* delims=\" %%i in ('dir c:\a /ad/s/b') do (
if 1%%k==1 (
if not exist d:\b\%%j md d:\b\%%j
copy c:\a\%%j d:\b\%%j
)
)
xcopy /e /q /r /h /y "C:\a" "D:\b\a\"