Windows 배치 파일의 for 루프 내부에서 배열 값에 액세스하는 방법에 대해 혼란스러워합니다. 배치 파일 : for 루프의 배열 요소 액세스
c:\temp\test\data does not exist
c:\temp\test\data\fonts does not exist
c:\temp\test\data\images does not exist
는 DIRS이 존재하더라도 : I 출력을 얻을
@ echo off
SET ROOT=c:\temp\test
REM set up array of local dir paths
SET LDIR[1]=data
SET LDIR[2]=data\fonts
SET LDIR[3]=data\images
for /L %%s in (1,1,3) do (
IF EXIST %ROOT%\%%LDIR[%%s]%% (
call echo %ROOT%\%%LDIR[%%s]%% exists
) else (
call echo %ROOT%\%%LDIR[%%s]%% does not exist
)
)
: 여기 내 테스트입니다. 배열이 IF EXISTS 문에서 제대로 derefernced되지 않습니다 믿습니다. 이 작업을 수행하는 올바른 방법은 무엇입니까? 또한 "call"을 사용하여 배열의 역 참조를 올바르게 얻는 것이 필요한 이유는 무엇입니까? - 감사합니다.
"% SVNROOT % \ %% LDIR [%% s] %%"이라면 시도해 보셨습니까? – volperossa
[이 게시물을 보시길 바랍니다.] (http://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990) – Aacini
Aacini, 네, 이것은 훌륭한 링크입니다. 고마워요! – webcoyote