如何让这个循环工作:
set list=am gp it ol
FOR %%a IN (%list%) DO (
set Indxed= %%a
ECHO %Indxed%
)
Echo总是输出到:ol ol ol ol。我该如何解决这个问题?
答案 0 :(得分:1)
测试一下:
@echo off
setlocal enabledelayedexpansion
set list=am gp it ol
FOR /f "delims=" %%a IN ("%list%") DO (
set Indxed=%%a
ECHO !Indxed!
)
答案 1 :(得分:0)
请尝试以下操作:
@echo off
setlocal
set list=am gp it ol
echo %list%
call :parse "%list%"
goto :eos
:parse
set list=%1
set list=%list:"=%
FOR /f "tokens=1* delims= " %%a IN ("%list%") DO (
if not "%%a" == "" call :sub %%a
if not "%%b" == "" call :parse "%%b"
)
goto :eos
:sub
echo %1
goto :eos
:eos
endlocal