I wanted to make a batch file with multiple else conditions and already searched a lot but mine is not working. I want the file to check if two files exists and if they do then open one of that files. If one of the two files do not exist the batch should compare the next two files. My file looks like that:
IF EXIST "file1.txt" IF EXIST "file2.txt" Goto V1
IF EXIST "file3.txt" IF EXIST "file4.txt" Goto V2
IF EXIST "file5.txt" AND IF EXIST "file6.txt" Goto V3
:V1
cd "folder"
start sample.exe
goto commonexit
:V2
cd "folder2"
start sample2.exe
goto commonexit
:V3
cd "folder3"
start sample3.exe
goto commonexit
:commonexit
Like this the cmd opens and immediately closes. When I comment out the ":commonexit" it opens and works throug the code but it seems like in the double IF conditions (IF ... IF...) it only cares about the second IF. Putting an AND operator between them does not help.
Has anyone of you a guess, what could be wrong?
EDIT: the :commonexit is working. I just did not know that a breakline after :commonexit would make the code corrupt.