From 2f636d094e247a68bb3ab38ce9aec43f13f648a9 Mon Sep 17 00:00:00 2001 From: Emily Grace Seville Date: Sat, 11 Dec 2021 14:30:29 +1000 Subject: [PATCH] if: add page (#7443) --- pages/windows/if.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 pages/windows/if.md diff --git a/pages/windows/if.md b/pages/windows/if.md new file mode 100644 index 0000000000..dd3f5a441f --- /dev/null +++ b/pages/windows/if.md @@ -0,0 +1,32 @@ +# if + +> Performs conditional processing in batch scripts. +> More information: . + +- Execute the specified commands if the condition is true: + +`if {{condition}} ({{echo Condition is true}})` + +- Execute the specified commands if the condition is false: + +`if not {{condition}} ({{echo Condition is true}})` + +- Execute the first specified commands if the condition is true otherwise execute the second specified commands: + +`if {{condition}} ({{echo Condition is true}}) else ({{echo Condition is false}})` + +- Check whether `%errorlevel%` is greater than or equal to the specified exit code: + +`if errorlevel {{exit_code}} ({{echo Condition is true}})` + +- Check whether two strings are equal: + +`if {{string}} == {{string}} ({{echo Condition is true}})` + +- Check whether two strings are equal without respecting letter case: + +`if /i {{string}} == {{string}} ({{echo Condition is true}})` + +- Check whether a file exist: + +`if exist {{path/to/file}} ({{echo Condition is true}})`