How can I use multiple conditions in “If” in batch file?

后端 未结 3 1859
余生分开走
余生分开走 2021-02-04 15:06

Can I specify multiple conditions with \"or\"/\"and\" in batch file if block?

If not that complex, can I at least use something like:

if val         


        
3条回答
  •  萌比男神i
    2021-02-04 15:55

    There are no logic operators in batch. But AND is easy to mimic with two IF statements

    if value1 lss value if value lss value2 REM do something
    

    Batch IF statements don't know how to compare times. Batch IF knows how to compare integers and strings.

    One option is to convert the times into minutes or seconds past midnight.

    The other option is to format the time with both hours, minutes (and seconds if needed) to be 2 digits wide each (0 prefixed as needed). The hours should be 24 hour format (military time).

提交回复
热议问题