string - batch expansion variable cannot be used in substring replace function -


im beginner, task renaming files in folder, first of here piece of code:-

setlocal enabledelayedexpansion set templogdate=0 set g=0  /r %targetstore% %%i in (*2013*.*) (   set templogdate=9   set g=!g:%templogdate%=! ) 

the problem variable %templogdate% value 0 instead of 9, know need use variable expansion(which have) cant replace code "set g=!g:%templogdate%.rar=!" "set g=!g:!templogdate!.rar=!", try escape character no result, guys pls me..thanks in advance

please delayed expansion, setlocal /? , endlocal /?. example:

@echo off &setlocal enabledelayedexpansion set "templogdate=0" set "g=0"  /r %targetstore% %%i in (*2013*.*) (   set "templogdate=9"   call set "g=%%g:!templogdate!=%%" ) 

Comments