AFAIK the working solution was kindly shared by TripeHound .... If you want to test both files exist, you want IF EXIST D:\ann.PDF IF EXIST D:\file.html ECHO
... The conditional command of the first IF is the second IF and if that is also true, the ECHO is executed. – TripeHound
The answers accepted here How to run two commands in one line in Windows CMD? are not working for me.
When I have only one 'IF EXIST ..' there is no problem. When I try having two on the same line using &, (or && in .bat) the batch file crashes or the CLI post an error "" & was unexpected at this time ""
This is the code I tried and the (very consistent) results
C:\Windows\system32> IF EXIST D:\file.html (ECHO this is good) ELSE (ECHO this really sucks)
this is good
response is "this is good" because both of the test files (ann.PDF and file.html) exist
C:\Windows\system32> IF EXIST D:\ann.PDF & IF EXIST D:\file.html (ECHO this is good) ELSE (ECHO this really sucks)
& was unexpected at this time.
I haven't got a clue why the 'unexpected' error is given.. any productive suggestions are welcome ... using Windows 7 x64 but solution has to also work on XP sp3 .... TVMIA !