Comparing two number in batch script

后端 未结 3 660
轻奢々
轻奢々 2020-11-28 00:16

I\'m sorry if it seems a very basic question, but I cant compare two file sizes where one file is being written continuously in batch script, it doesn\'t go beyond if statem

相关标签:
3条回答
  • 2020-11-28 00:19

    One issue is the parenthesis after the if compare - it must be on the same line:

     if %size% EQU %parsize% (
    
    0 讨论(0)
  • 2020-11-28 00:36
    if cond ( 
    ...
    ) else (
    ...
    )
    
    if cond (...) else (...)
    if cond (...) else command
    if cond (...) else (
        ....
    )
    if cond (
        ....
    ) else command
    

    The placement of the parenthesis matters. The if opening parenthesis needs to be on the same line that the if command. The if closing parenthesis needs to be in the same line that the else clause (if present). The else opening parenthesis needs to be in the same line that the else clause.

    0 讨论(0)
  • 2020-11-28 00:39

    if %size% EQU %parsize% causes error

    if opp condition opp2 command
    

    if you modify follow this this will work

    IF %size% == %parsize%   ECHO file is complete > C:\Users\finoy\status.log   ping -n 5  127.0.0.1 > nul 
    else echo incomplete > C:\Users\finoy\status.log ping -n 5 127.0.0.1 > nul
    
    0 讨论(0)
提交回复
热议问题