user1787480
user1787480

Reputation: 21

Delayed expansion not working for a for loop

I have this batch script and I am calling another batch script "Strip_Batch.bat" and passing %Stripped_Name% variable as parameter. But this parameter doesnt work. Any idea how I can pass this variable?

@echo off
setlocal enableextensions enableDelayedExpansion
set CONFIGURATIONS=HAVING_FUN_WITH_COLLEGUES
for %%i in (%CONFIGURATIONS%) do (
set Original_Name=%%i
echo !Original_Name!
set Stripped_Name=!Original_Name:~0,-14!
echo !Stripped_Name!
call Strip_Batch.bat %%i %Stripped_Name%
if errorlevel 1 goto error_exit
) 

:the_end
endlocal
exit /b 0

:error_exit
endlocal
exit /b 1

Upvotes: 2

Views: 309

Answers (1)

Endoro
Endoro

Reputation: 37569

according to my comment I'd suggest first:

call Strip_Batch.bat %%i !Stripped_Name!

and second (better, works also for parameter with spaces):

call Strip_Batch.bat "%%i" "!Stripped_Name!"

Upvotes: 1

Related Questions