I'm comparing two folders of pdf files. First I check which files are new and save all new files in an array anew:
setlocal enabledelayedexpansion
FOR /F "delims=. tokens=1" %%I IN ('dir "%Rev2Dir%\*.pdf" /b') DO (
if not exist "%Rev1Dir%\%%I.pdf" (
IF NOT EXIST new.txt (
ECHO %%I new > new.txt
) ELSE (
ECHO %%I new >> new.txt
)
ECHO %%I.pdf ^(new^)
copy "%Rev2Dir%\%%I.pdf" "%Rev1Dir%\%%I.pdf"
set /A i=i+1
set anew[!i!]=%%I
)
)
This works fine. I'm able to display all those files with:
set k=%i%
for /L %%i in (1,1,%k%) do echo file number %%i: "!anew[%%i]!"
Now it's getting tricky. Within an other loop, I'm checking whole first folder and need to know if the file is new or not:
FOR /F "delims=. tokens=1" %%I IN ('dir "%Rev1Dir%\*.pdf" /b') DO (
IF EXIST "%Rev2Dir%\%%I.pdf" (
echo file is %%I
echo j is !j!
if "%%I" == "!anew[%j%]!" (
set /A j=j+1
ECHO %%I.pdf ^(new^)
) Else (
echo do someting
)
)
The issue is, that !anew[%j%]! is still anew[1]. The variable j will not update. For my echo it works fine. So I guess I need something like !anew[!j!]! (which does not work) Can someone assist.