@echo off set testconf=abc if "%testconf%"=="!testconf!" goto okcmd echo You mist activate extended expansion of variables echo calling cmd with /V:ON option. After that, you can echo re-execute me to obtain the output that you can check echo and then execute as batch, in order to rename the shortcuts exit /B 1 :okcmd @for %%j in (*.lnk) do ( @set nome=%%~fj @set nomep=%%j rem Instead of "Shortcut to " you can put your language specific rem string, e.g. "Collegamento a " in Italian. Should this string rem be taken from somewhere? But... from where? if "!nomep:~0,15!" == "Shortcut to " @echo rename "!nome!" "!nomep:Shortcut to =!" ) rem now we do the same in the subfolders, and rem so on... set nomecmd=%~f0 @for /D %%i in (*) do ( @pushd %%i "%nomecmd%" @popd )