@echo off for /r /d /s %%d in (*.*) do ( if exist "%%d\\(1).txt" ( rename "%%d\\(1).txt" "%%d(-123).txt" ) )