I'm trying to compare two arrays in batch script, but I'm afraid I'm doing it wrong. The code below retrieves the first 12 bytes from a file and tries to compare it with a given format.
Could you help help me with the TODO part?
PS: I'm not sure if I'm using the array variables correctly..
@echo off
SETlocal enabledelayedexpansion
SET read_byte_cmd=powershell -command Get-Content -encoding Byte -TotalCount 12 "'DB.accdb'"
SET ACCESS_BYTES[0]=0
SET ACCESS_BYTES[1]=1
SET ACCESS_BYTES[2]=0
SET ACCESS_BYTES[3]=83
SET ACCESS_BYTES[4]=116
SET ACCESS_BYTES[5]=97
SET ACCESS_BYTES[6]=110
SET ACCESS_BYTES[7]=100
SET ACCESS_BYTES[8]=97
SET ACCESS_BYTES[9]=114
SET ACCESS_BYTES[10]=100
SET ACCESS_BYTES[11]=32
echo list array --------------------
SET ACCESS_BYTES[
echo\
echo list file bytes --------------
set i=0
for /f "tokens=1 delims==" %%i in ('%read_byte_cmd%') do (
set /A i+=1
echo %read_byte_array[!i!]%=%%i
)
echo\
echo list values only --------------
for /f "tokens=2 delims==" %%i in ('SET ACCESS_BYTES[') do echo %%i
echo\
echo comparison --------------------
:: TODO compare ACCESS_BYTES[i] with read_byte_array[i], if equal success..
0, but in yourforloop you start to index with1(enter theforwithi=0, adding one, thenecho...[!i!]. Intention or logical quirk?;as delimiter if needed) to see if they are equal.