@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
SET "destdir=U:\destdir"
FOR /f "delims=" %%a IN (
'dir /s /b /a-d "%sourcedir%\*" '
) DO (
IF EXIST "%destdir%\%%~nxa" (
SET notfound=Y
FOR /L %%b IN (1,1,999) DO IF DEFINED notfound IF NOT EXIST "%destdir%\%%~na(%%b)%%~xa" (
ECHO(COPY "%%a" "%destdir%\%%~na(%%b)%%~xa"
SET "notfound="
)
IF DEFINED notfound ECHO(Failed to COPY "%%a"
) ELSE (ECHO(COPY "%%a" "%destdir%\%%~nxa"
)
)
GOTO :EOF
The required COPY commands are merely ECHOed for testing purposes. After you've verified that the commands are correct, change ECHO(COPY to COPY to actually copy the files.
Naturally, the copy could become move if you prefer.
The destination directory should not be a subdirectory of the source.
You could add >nul to the copy to suppress the copied message if desired.
I've used a mask of * for all files. If you only want say .jpgs, then change "%sourcedir%\*" to "%sourcedir%\*.jpg"