I have two text files, one stores the name of files I need to copy and one the addresses to where i want to copy them. My idea was to create two arrays to store that information and then loop through them both so that I always get the filename and the corresponding address. This is the code I use to store the information in the arrays:
@echo off
set /A i=0
set x=0
for /F "usebackq delims=" %%a in ("Name.txt") do (
set /A i+=1
call echo %%i%%
call set NAME_ARRAY[%%i%%]=%%a
call set n=%%i%%
)
set /A i=0
for /F "usebackq delims=" %%a in ("Adress.txt") do (
set /A i+=1
call echo %%i%%
call set ADRESS_ARRAY[%%i%%]=%%a
call set n=%%i%%
)
And then I loop through the two arrays and try to things with them:
for /L %%j in (1,1,%n%) do (
:: subproject dir, relative to the sandobox dir
set SUBPROJECT_DIR=%ADRESS_ARRAY[%%j]%
:: sandbox name
set SANDBOX_NAME=C:\%SANDBOX_FOLDER_NAME%\%SUBPROJECT_DIR%\project.pj
:: name of sandbox folder
set SANDBOX_DIR=C:\%SANDBOX_FOLDER_NAME%\%SUBPROJECT_DIR%
:: name of presentation to be copied
set PRESENTATION_NAME=%NAME_ARRAY[%%j]%
:: check out file with software version number
si co --sandbox=%SANDBOX_NAME% --changePackageId=:none --hostname=%SERVERNAME% --port=%PORTNAME% %SANDBOX_DIR%\%PRESENTATION_NAME%
:: Copying new files (Option /xo of robocopy)
robocopy x: %SANDBOX_DIR% %PRESENTATION_NAME%
:: check in modified file
si ci --sandbox=%SANDBOX_NAME% --changePackageId=:none --hostname=%SERVERNAME% --port=%PORTNAME% %SANDBOX_DIR%\%PRESENTATION_NAME%
)
My problem is, that I can't seem to read the array through the indexes. set SUBPROJECT_DIR=%ADRESS_ARRAY[%%j]%
and set PRESENTATION_NAME=%NAME_ARRAY[%%j]%
don't seem to set the variables, they remain empty. Does anybody know why?