在if条件下批处理文件的多个操作 [英] batch file multiple actions under a if condition
本文介绍了在if条件下批处理文件的多个操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将多个操作置于if条件下?像这样:
Is there a way to put multiple actions under a if condition? Like this:
if not exist MyFolderName (
ECHO create a folder
mkdir MyFolderName
)
推荐答案
您可以使用& ;
加入命令并在同一行执行它们。
You can use &
to join commands and execute them on the same line.
所以您的语法应如下所示:
So your syntax should look like:
if not exist MyFolderName ECHO "Create a folder" & mkdir MyFolderName
更新
或者您可以使用标签跳转到包含要执行的命令的部分,例如:
Or you can use labels to jump to a section containing the commands you want to execute, for example:
if not exist MyFolderName GOTO DOFILESTUFF
:AFTER
...
EXIT
:DOFILESTUFF
ECHO "Create a folder"
mkdir MyFolderName
GOTO AFTER
这篇关于在if条件下批处理文件的多个操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文