@echo off
set num=0
for /f "delims=" %%i in ('dir /a-d /b e:\A\*.txt') do (
if not exist "e:\B\%%i" (
copy "e:\A\%%i" e:\B>nul
) else call :copy_txt "e:\A\%%i" "%%~ni" %%~xi
)
goto :eof
:copy_txt
set file_n=%2
set "file_n=%file_n:~1,-1%"
set file_x=%3
set /a num+=1
if not exist "e:\B\%file_n%%num%%file_x%" (
copy %1 "e:\B\%file_n%%num%%file_x%">nul
) else call :copy_txt %1 "%file_n%" %file_x%
set num=0
goto :eof