Ok, so my end goal is to iterate through a text file, and for each line in the text file, use that line as a key in an array to store a value of 1.
Then, loop through files in a directory and see if there is a value in the aforementioned array for the current filename in this iteration.
My code is as follows
@echo off
setlocal enabledelayedexpansion
set filesRan[0]=1
set i=0
for /f "tokens=*" %%a in (input.txt) do (
set /A i+=1
set filesRan[%%a]=1
)
set patchesRan[0]=1
for %%f in ("C:\Users\kkennedy\Source\Repos\GeneSeek-DataHub\dbScripts\DDL\Patches\*") do (
echo %%f
echo %%~nf
set thisFileName=%%~nf
echo triple x !thisFileName!
echo triple x !filesRan[%%thisFileName]!
IF "!filesRan[%%thisFileName]!" EQU "1" (
ECHO already ran it
) ELSE (
ECHO did not run it
)
set patchesRan[!%%~nf!]=1
)
The exact line that is not producing the results I'm expecting is:
echo triple x !filesRan[%%thisFileName]!
I'm coding a bit blindly here with batch, so I'm guessing it is something fairly simple. For instance, is my syntax correct for referencing the array item?