if else [solved]
Posted: 23 Feb 2023 07:32
Hello together,
i have a problem with a simple task.
This is my one-line-code which is directly run in cmd.exe (not in an Batch-File):
My Problem is, that the code echos only "not there" if the test.txt doesn't exist. But it doesn't echo the "let's do the next things".
The Task should check if the file exists or not and no matter what the result is, it should continue wich the statement after the last &.
Unfortunately it interprets the "& echo "let's do the next things" as a part of the else statement.
I can't solve it in a batch file because of restrictions, so i need to do it directly on the prompt line.
It would be great, if someone can help me.
I am using windows 10.
Kind regards
Stefan
i have a problem with a simple task.
This is my one-line-code which is directly run in cmd.exe (not in an Batch-File):
Code: Select all
C:\Temp>if not exist test.txt ( echo "not there" ) else ( echo "it's there" ) & echo "let's do the next things"
The Task should check if the file exists or not and no matter what the result is, it should continue wich the statement after the last &.
Unfortunately it interprets the "& echo "let's do the next things" as a part of the else statement.
I can't solve it in a batch file because of restrictions, so i need to do it directly on the prompt line.
It would be great, if someone can help me.
I am using windows 10.
Kind regards
Stefan