How can I compare two files in a batch file?

后端 未结 3 1364
-上瘾入骨i
-上瘾入骨i 2021-02-04 05:04

How can I compare two files in a batch file, and perform an action based on whether or not they match? I\'ve tried something like:

if file1.txt NEQ file2.txt got         


        
3条回答
  •  隐瞒了意图╮
    2021-02-04 05:30

    I believe you can use the "FC" command and then check the errorlevel. Here's some code:

    @echo off
    :main
    fc c:\filename r:\filemame > nul
    if errorlevel 1 goto error
    
    :next
    echo insert next CD
    pause
    goto main
    
    :error
    echo failed check
    

    (Pulled from http://www.computing.net/answers/dos/batch-file-command/15753.html)

提交回复
热议问题