I am writing a simple batch file that needs to perform its actions IFF (if and only if) exactly 2 files and 2 folders are present inside a specific folder. The file and folder names must match exactly, which makes this relatively easy.
In pseudo-code this is:
IFF folder `FOO` contains (file `a.txt` AND file `b.txt` AND folder `f1` AND folder `f2`) THEN ...
BTW, the code after the THEN ... is all done. No problem there.
Here is my code:
IF EXIST a.txt goto good1
goto done
:good1
IF EXIST b.txt goto good2
goto done
:good2
IF EXIST f1 goto good3
goto done
:good3
IF EXIST b.txt goto good4
goto done
:good4
echo requirements met
:done
I can use IF EXIST to handles the IF part of the IFF (IF and ONLY IF), but how can I ensure other files/folders are not present in folder FOO?
Ideally, I would like to keep this simple without creating temporary files caused by piping or stdout redirection to a file.
Aucun commentaire:
Enregistrer un commentaire