Код:
@echo off
setlocal enableextensions enabledelayedexpansion
set sSourceFolder=C:\1
set sDestFolder=C:\2
if exist "%sSourceFolder%" (
if exist "%sDestFolder%" (
pushd "%sSourceFolder%"
for /f "usebackq delims=" %%i in (
`2^>nul dir /b /a:-d`
) do (
set sDestPath=%sDestFolder%\%%~xi
if not exist "!sDestPath!" md "!sDestPath!"
echo [%%~i] ---^> [!sDestPath!]
>nul move "%%~i" "!sDestPath!\"
)
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