Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a variable containing some words separated by one space, like this
set VAR=word1 word2 word3
Is it possible to have a FOR loop which loops over the word? Something similar in spirit to
rem call mybatch word1
rem call mybatch word2
rem etc.
for %%i in (%VAR%) do call mybatch %%ionly that written in this way, it's syntactically not valid.

@echo off & setLocal EnableDELAYedExpansion
set VAR=word1 word2 word3
for /f "tokens=1-3 delims= " %%a in ("!VAR!") do (
call mybatch %%a
call mybatch %%b
call mybatch %%c
)
=====================================
Helping others achieve escape felicityM2

This did not work. For example, executing the following Batch file:
@echo off
setlocal ENABLEDELAYEDEXPANSION
set PROD_DIRNAME_IALL=I1 I2
for %d in (%PROD_DIRNAME_IALL%) do echo xxx %%dproduces the error message
"PROD_DIRNAME_IALLd" ist syntaktisch an dieser Stelle nicht verarbeitbar.
which means that there is a syntax error in the FOR statement.

"This did not work"
%d should be %%d
=====================================
Helping others achieve escape felicityM2

![]() |
Using a Modulus Help
|
synchronise 2 folder stru...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |