I'm trying to figure out how to get this nested loop to work without delayedexpansion. My original block shown below works as intended, but after writing it, I discovered I can't save the changes to my variables after ending the local:
setlocal enabledelayedexpansion
REM Identify annual apps that will be updated
echo Discovering apps to update...
set ANNUALAPPSIZE=0
for /l %%a in (0,1,%APPSIZE%) do (
set CURRENTAPP=!APP[%%a]!
for %%b in ("%CURPATH%\Packages\!CURRENTAPP!\*") do (
echo !%%b! | findstr /c:"IncludeInAnnualUpdates.txt" >nul
if !errorlevel! equ 0 (
set "ANNUALAPP[%ANNUALAPPSIZE%]=!CURRENTAPP!"
)
)
)
endlocal
The methods I was finding of ending the local while saving the changes made to the ANNUALAPP array did not seem very functional / were very ugly.
I'm this far into re-writing the block and it keeps crashing when it gets to the nested loop:
for /l %%a in (0,1,%APPSIZE%) do (
call set CURRENTAPP=%%APP[%%a]%%
for %%b in ("%CURPATH%\Packages\%CURRENTAPP%\*) do (
pause
)
)
I tried %%APP[%%a]%% in place of %CURRENTAPP% in the nested for loop. As well as %%CURRENTAPP%% in case it was an expansion thing.
...Packages\%CURRENTAPP%\*...
has to be delayed (as in your first example)ANNUALAPP
array from the first routine? Are you picky about how it's done (ie. could you use a tempfile?) The second routine has unbalanced rabbits' ears.