I want to replace '_
' by '-
' in file names. however, dos can't recognize the variable value(%str%
) in do loops, it works well outside of the loop(%str1%
can be displayed), does anyone have an idea about it? thank you in advance!
codes:
@echo off
pushd "C:\Users\Documents\tasks\STATS\27feb\try" || exit /b
set str1=jump1_over_the_chair
set str1=%str1:_=-%
echo str1=%str1%
for /f %%a in ('dir /b /a-d *.doc') do (
set "File=%%a"
set str=jump_over_the_chair
set str=%str:_=-%
echo %str%
pause
ren "%%a" "%str%"
)
popd