I assume that you will also want to rename the files in the subfolders in which you had problems sending your second comment to Martin James. I assume you tried this code with the DIR / S option. But you were so close :-) You just had to use 2 cycles!
Change - fixed code . Once the result looks right, drop ECHO to make it work.
@echo off
for /r %%D in (.) do (
pushd "%%~fD"
for /f "tokens=1-3 delims=_." %%A in ('dir /b *_ex.ext 2^>nul') do echo ren "%%A_%%B.%%C" "%%A.%%C"
popd
)
, _ ., , _ex.ext. , .
, ( Unicode). . , , . 3 . ECHO , .
@echo off
setlocal disableDelayedExpansion
for /f "delims=" %%F in ('dir /b /s *_ex.ext') do (
set "old=%%F"
set "new=%%~nF"
setlocal enableDelayedExpansion
echo ren "!old!" "!new:~0,-3!.ext"
endlocal
)