Код:

@echo off
setlocal enableextensions enabledelayedexpansion
set sSourceFolder=r:\
set sDestFolder=d:\1
set sMask="*КМ*.*" "*КЖ*.*"
if exist "%sSourceFolder%\." (
if exist "%sDestFolder%\." (
pushd "%sSourceFolder%" && (
for /f "usebackq delims=" %%i in (`2^>nul dir /b /a:d %sMask%`) do (
if not exist "%sDestFolder%\%%~i\." md "%sDestFolder%\%%~i"
xcopy.exe "%%~i\*.*" "%sDestFolder%\%%~i\" /e /f /h /r /y
)
popd
)
) else (
echo Can't find destination folder [%sDestFolder%].
exit /b 2
)
) else (
echo Can't find source folder [%sSourceFolder%].
exit /b 1
)
endlocal
exit /b 0