0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[バッチ] if文を使って条件分岐

Posted at

もくじ
https://qiita.com/tera1707/items/4fda73d86eded283ec4f

やりたいこと

バッチで、if文を使って条件分岐をしたい。

書き方

ifbun.bat
set FLAG=0
if %FLAG% == 1 (
	echo FLAG is 1
) else (
	echo FLAG is 0
)
  • 「(」や「)」だけ改行してはいけない。
  • ifの中でset FLAG=1などすると、それが反映されるのはif文を抜けた後。
  • なので、if文の中に具体的な処理を書かない方がよい。参照

参考

バッチファイルでif文をトラブルなく使う
https://qiita.com/ejiw/items/8a6ac11c117b6695b6ca

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?