@echo off setlocal enabledelayedexpansion for /f %%i in ('dir /b *.*') do ( set var=%%~nxi set "var=!var:est=!" echo !var!) pause