@echo off Setlocal Enabledelayedexpansion set "str= " for /f "delims=" %%i in ('dir /b *.*') do ( set "var=%%i" & ren "%%i" "!var:%str%=!")