| 1. |
Solve : How to compare 2 text files in a script?? |
|
Answer» Hello Yep, noticed that too. I will give it a try. I am sure it will work.Quote from: BC_Programmer on November 03, 2010, 05:46:46 PM to my understanding FC doesn't return an errorlevel. That's odd because I thought it returned 0 if the files are the same, 1 if they are different, and 2 if one or both files do not exist. Code: [Select]echo off echo hello > test1.txt copy test1.txt test2.txt>nul echo goodbye > test3.txt fc test1.txt test2.txt>nul echo Compare 2 identical files errorlevel=%errorlevel% fc test1.txt test3.txt>nul echo Compare 2 different files errorlevel=%errorlevel% fc test1.txt test4.txt 2>1>nul echo compare file with nonexistent file errorlevel=%errorlevel% fc test5.txt test4.txt 2>1>nul echo compare two nonexistent files errorlevel=%errorlevel% Code: [Select]Compare 2 identical files errorlevel=0 Compare 2 different files errorlevel=1 compare file with nonexistent file errorlevel=2 compare two nonexistent files errorlevel=2 Identical output on Windows XP Professional 32 bit SP3 and Windows 7 64 bit Professional. Am I being dumb here and missing something? cool, that should make the script even shorter then; just a quick errorlevel check in the original script presented by the OP would have done the trick. For some reason I didn't even check if fc actually returned errorlevels. But you know what they say, assuming makes an *censored* out of u and some guy named ming, guess that's what I did. |
|