How-To Guide

    FC Command in Windows: How to Compare Two Files in CMD

    Syntax, every switch, real output, errorlevels for batch files, and the reason fc does nothing in PowerShell.

    Published November 24, 2026Updated November 24, 20268 min read
    Mehrab Ali

    Author

    Mehrab Ali

    Founder & Executive Lead, ARCED International

    Founder of ARCED Foundation, ARCED International, and Solutions of Things Lab (SoTLab). Built FolderManifest to help teams protect file integrity and stay audit-ready.

    Quick Answer

    The fc (File Compare) command in Windows compares two files and prints what differs. In Command Prompt run fc /n old.txt new.txt for a line-by-line text comparison with line numbers, or fc /b file1 file2 for a byte-by-byte comparison of any file type. Identical files print FC: no differences encountered. In PowerShell, type fc.exe.

    fc has shipped with Windows since the MS-DOS days and is still there in Windows 10 and 11 as C:\Windows\System32\fc.exe. Nothing to install. Every command and output block below was run on Windows 11 and is shown as printed.

    fc Command Syntax and Switches

    FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn] file1 file2
    FC /B file1 file2

    Switches go before the file names. Put quotes around paths that contain spaces. Run fc /? to see the built-in help.

    SwitchWhat it does
    /nShow line numbers in a text comparison. The one switch worth using every time.
    /cIgnore the case of letters (Server = SERVER).
    /wCompress runs of tabs and spaces into one before comparing, so re-indented lines still match.
    /aAbbreviated output: show only the first and last line of each differing block.
    /bBinary comparison, byte by byte. Cannot be combined with the text switches.
    /lForce a text (ASCII) comparison, even for .exe, .bin and other extensions fc treats as binary.
    /uCompare the files as Unicode (UTF-16) text.
    /tDo not expand tabs to spaces. By default tabs are expanded before comparing.
    /lbnMaximum consecutive mismatched lines (default 100) before fc gives up with "Resync Failed".
    /nnnnNumber of consecutive lines that must match after a mismatch before fc treats the files as back in sync (default 2).
    /offDo not skip files that have the offline attribute set.

    With no switches, fc does a text comparison unless the file extension is .exe, .com, .sys, .obj, .lib, or .bin, which it compares as binary.

    Compare Two Text Files with fc

    Two small config files: new.txt has a different port on line 2 and an extra line 6.

    C:\work> fc /n old.txt new.txt
    Comparing files old.txt and NEW.TXT
    ***** old.txt
        1:  server=alpha
        2:  port=8080
        3:  debug=false
    ***** NEW.TXT
        1:  server=alpha
        2:  port=9090
        3:  debug=false
    *****
    
    ***** old.txt
    ***** NEW.TXT
        6:  retries=3
    *****

    How to read it:

    • Each difference is a block that starts with ***** file1, continues with ***** file2, and ends with a bare *****.
    • fc prints one matching line of context before and after the change. Here only line 2 actually differs; lines 1 and 3 are the same in both files and are shown so you can find the spot.
    • An empty section means that file has nothing there. In the second block old.txt is empty and new.txt has retries=3: the line was added.
    • The second file name is printed in upper case (NEW.TXT). That is a display quirk, not a different file.

    To keep the result, redirect it to a file: fc /n old.txt new.txt > diff.txt. On long differing blocks, add /a to print only the first and last line of each block.

    Ignore Case and Spacing: /c and /w

    Say a third file has SERVER=alpha in capitals and debug = false with extra spaces. A plain fc flags both lines. With /c and /w:

    C:\work> fc /c /w old.txt case.txt
    Comparing files old.txt and CASE.TXT
    ***** old.txt
    port=8080
    debug=false
    timeout=30
    ***** CASE.TXT
    port=8080
    debug =  false
    timeout=30
    *****

    /c made server and SERVER equal, so that line dropped out. The debug line is still reported: /w compresses runs of spaces and tabs into one, it does not remove them, so debug=false (no space) and debug = false (one space) remain different. /w helps with re-indented or re-aligned files, not with spaces added where there were none.

    Binary Compare: fc /b

    For images, PDFs, archives, executables, or any time you want a strict answer, use /b:

    C:\work> fc /b old.txt new.txt
    Comparing files old.txt and NEW.TXT
    00000013: 38 39
    00000015: 38 39
    FC: NEW.TXT longer than old.txt

    Each line is a hexadecimal offset counted from 0, then the byte in the first file, then the byte in the second. Offset 0x13 holds 38 (the character 8) in one file and 39 (9) in the other. The last line tells you one file has extra bytes at the end. For hex diffs, the comp command, and cmp on Mac and Linux, see our guide to comparing binary files.

    If all you need is same-or-different, a hash is faster to read than a list of offsets. The free Compare Files tool takes two files up to 10 MB each, computes SHA-256 in memory on our server without storing them, and tells you whether they are identical. On the command line, certutil -hashfile does the same job.

    Use fc in a Batch File

    fc sets errorlevel so a script can act on the result without parsing text:

    errorlevelMeaning
    0Files are identical
    1Files differ
    2A file could not be opened
    :: One-liner
    fc /b a.bin b.bin >nul && echo SAME || echo DIFFERENT
    
    :: In a script
    @echo off
    fc /b "%~1" "%~2" >nul
    if errorlevel 2 (echo Could not open a file & exit /b 2)
    if errorlevel 1 (echo Files differ & exit /b 1)
    echo Files are identical

    >nul hides the comparison text. if errorlevel 2 means “2 or higher”, so test the larger number first. %~1 strips any quotes from the argument before the script adds its own, which keeps paths with spaces working when files are dragged onto the .bat.

    Wildcards compare same-named files in two places, one pair after another:

    C:\work> fc A\*.txt B\*.txt
    Comparing files A\x.txt and B\x.TXT
    ...
    Comparing files A\y.txt and B\y.TXT
    FC: no differences encountered

    In our test the errorlevel after a wildcard run was 1 because one pair differed, even though the last pair matched. For per-file results, loop instead: for %f in (A\*.txt) do @fc /b "%f" "B\%~nxf" >nul || echo %~nxf differs (double the % signs inside a batch file).

    fc in PowerShell: Type fc.exe

    In PowerShell, fc is an alias for the Format-Custom cmdlet. Typing fc old.txt new.txt runs that cmdlet instead of the file compare program, and nothing is compared. Call the program by its full name:

    PS> (Get-Alias fc).Definition
    Format-Custom
    
    PS> fc.exe /n old.txt new.txt
    
    # Native PowerShell alternative
    PS> Compare-Object (Get-Content old.txt) (Get-Content new.txt)
    
    InputObject SideIndicator
    ----------- -------------
    port=9090   =>
    retries=3   =>
    port=8080   <=

    => marks lines only in the second file, <= lines only in the first. Compare-Object ignores line order and shows no line numbers, so fc.exe /n is often easier to read for config files and logs.

    Common fc Errors and What They Mean

    • FC: cannot open FILE - No such file or folder. Wrong path or name (errorlevel 2). Check the current folder with cd and quote paths with spaces.
    • Resync Failed. Files are too different. More consecutive lines differ than the line buffer holds (100 by default). Raise it, for example fc /lb1000 a.log b.log, or accept that the files have little in common.
    • FC: Invalid Switch. A switch fc does not know. Check it against the table above, and use backslashes in paths: in our test fc a/x.txt b/x.txt failed with cannot open while fc a\x.txt b\x.txt worked.
    • Output with a blank line between every line, or odd spacing. The files are UTF-16 (for example saved by PowerShell 5 with > or as “Unicode” in Notepad). Add /u.
    • Text mode says identical, /b says different. Text mode ignores line-ending style: in our test a Windows (CRLF) file and a Unix (LF) copy of it gave no differences encountered. The bytes still differ, and fc /b or a hash will show it.

    Not the Linux fc

    In Bash and zsh, fc is a shell built-in that lists and re-runs commands from your history. It has nothing to do with comparing files. On Linux and macOS use diff for text and cmp for binary files.

    Where fc Stops Being Enough

    • No side-by-side view. Output is plain blocks of text. For long documents a visual diff tool such as WinMerge (free, Windows) is easier to read.
    • comp is not an upgrade. Windows also ships comp, which is binary only, stops after 10 mismatches, and refuses files of different sizes. Stick with fc /b.
    • Folders. fc with wildcards pairs up same-named files in one folder level. It does not walk subfolders and does not produce a list of files that exist on only one side.

    For two whole folders, start with robocopy /L or the other built-in methods in our guide to comparing two folders on Windows. When you need proof that a copy, backup, or migration arrived intact, FolderManifest records every file with its path, size, dates, and SHA-256 hash, then compares two folders (or a folder against a saved manifest) and lists exactly which files were added, removed, or changed. It runs locally on Windows 10/11, macOS, and Linux. It tells you which files changed, not which lines inside them; fc is still the right tool for that last step.

    Frequently Asked Questions

    What does the fc command do in Windows?

    fc (File Compare) compares two files, or two sets of files, and prints the differences in the Command Prompt window. Text files are compared line by line; with /b it compares byte by byte. It is built into every version of Windows as C:\Windows\System32\fc.exe.

    How do I compare two text files in CMD?

    Open Command Prompt and run fc /n file1.txt file2.txt. fc prints each block of lines that differs, first from file1 and then from file2, with line numbers. If the files match it prints "FC: no differences encountered".

    Why does fc not work in PowerShell?

    In PowerShell, fc is a built-in alias for the Format-Custom cmdlet, so it never reaches the file compare program. Type fc.exe instead, for example fc.exe /n old.txt new.txt, or use Compare-Object (Get-Content old.txt) (Get-Content new.txt).

    What does "FC: no differences encountered" mean?

    It means the two files are identical under the comparison you asked for. With /c or /w that can still hide case or spacing differences, because those switches tell fc to ignore them. Run fc /b for a strict byte-for-byte answer.

    What is the difference between fc and comp?

    fc compares text line by line (or bytes with /b), accepts files of different lengths, and lists every difference. comp is binary only, reports byte offsets, stops after 10 mismatches, and refuses files of different sizes. For most jobs fc is the better choice.

    What errorlevel does fc return?

    fc sets errorlevel 0 when the files are identical, 1 when they differ, and 2 when a file cannot be opened. That makes it usable in batch scripts: fc /b a.bin b.bin >nul && echo SAME || echo DIFFERENT.

    Can fc compare two folders?

    Only loosely. With wildcards, such as fc A\*.txt B\*.txt, it compares files that have the same name in both folders. It does not go into subfolders and does not give you a list of files that are missing or extra. Use robocopy /L, a folder compare tool, or SHA-256 manifests for whole folders.

    Compare Whole Folders, Not One File at a Time

    Record every file with its SHA-256 hash, then check any later copy against it. Windows, Mac, and Linux. 7-day free trial, no card required, 30-day money-back guarantee.

    Continue Learning