guide · command line

Compare two folders from the command line

A batch file that checks a deployment against the build, a PowerShell script that wants to know what changed since yesterday, a scheduled look at a copy: sometimes a folder comparison has to run without anyone watching. Diffoniq compares two folders from the command line, writes the result as an HTML page, plain text or JSON, and tells your script through its exit code whether the folders differ.

The short version: run DiffoniqC.exe /report with both folders, an output file and --content, as in step 1. Exit code 0 means the folders are the same, 1 that the report lists the differences.

1. Call DiffoniqC.exe, not Diffoniq.exe

Diffoniq.exe is a windowed program: a command prompt does not wait for it and never sees its exit code. Next to it sits DiffoniqC.exe, a small console companion. It takes the same arguments, starts Diffoniq, waits until the job is done, prints the log lines and hands back the exit code. Call it with its full path; the installer does not add Diffoniq to PATH. C:\Program Files\Diffoniq\ is the installer’s folder; in the portable version both programs sit in the folder you unpacked. In a command prompt:

"C:\Program Files\Diffoniq\DiffoniqC.exe" /report "D:\project" "E:\project-copy" --out changes.html --content

2. Write the report

/report takes the left and the right folder and the file to write with --out. The extension picks the format: .html gives a single self-contained page, .txt plain text, .json a document for programs; --format html|text|json sets it explicitly. A relative name lands in the current folder, missing folders are created, and the file appears only when it is complete, so a script never picks up half a report. Nothing in the compared folders is changed.

Keep --content. With it, files of the same size are read on both sides and compared by content. Without it, no file is read: pairs of the same size are listed as not compared, never as identical. Either side may also be a ZIP file or another archive, and two files instead of two folders give a file report with the changed lines.

HTML report of a folder comparison written by /report: header with the left and right folder, the options in effect, the summary 10 items compared, 2 different, 3 only left, 1 only right, 4 identical, 1 renamed or moved, and a table with one coloured row per difference
The HTML report. The header names both folders and the options in effect. Identical files are counted, not listed, so what you read is the list of changes; --include-equal lists them too.

3. Let the exit code decide

Exit codeMeaning
0Report written, no differences
1Report written, differences found
2The report file could not be written
3Invalid arguments, or the comparison failed, for example on a folder that cannot be read; the log names the cause

In a batch file:

"C:\Program Files\Diffoniq\DiffoniqC.exe" /report "D:\project" "E:\project-copy" --out changes.html --content
if %errorlevel% equ 0 echo The folders are the same.
if %errorlevel% equ 1 echo Differences found, see changes.html.

In PowerShell, start it with & in front of the quoted path and read $LASTEXITCODE. In Git Bash, write the switch as //report, because the shell turns /report into a path. Every run also writes a log file, by default to %APPDATA%\Diffoniq\report\, where the 30 newest are kept. Ctrl+C stops a run; it then writes no report. Details: Scripting and AI Assistants.

4. Read the result in PowerShell

When a script has to act on the differences rather than count them, ask for JSON:

& "C:\Program Files\Diffoniq\DiffoniqC.exe" /report "D:\project" "E:\project-copy" --out report.json --content
$r = Get-Content report.json -Raw | ConvertFrom-Json
$r.summary
$r.entries | Where-Object { $null -eq $_.right } | ForEach-Object { $_.left.path }

The summary counts every state. Each entry carries its status and both sides with path, size and time stamp; a side that does not exist is null, so the last line lists what is missing on the right. The states are different, onlyLeft, onlyRight, identical, unverified and notCompared; treat the last two as unknown, never as identical. The same lines work in PowerShell 7 and in Windows PowerShell 5.1. Every key is described under Comparison Reports.

5. Narrow the list

A large comparison can list thousands of entries. These switches shorten the list; the summary still counts everything.

SwitchEffect
--only onlyLeft,onlyRightlist only what exists on one side; any of the states above can be named
--exclude "build;*.obj"leave out files and folders matching these patterns, on both sides
--gitignoreapply the .gitignore rules of both folders
--under srclist only what lies below this folder; the comparison still covers both trees
--collapsea folder that exists on one side only takes one line, with the number and size of what lies inside
--folders 5start with the five folders that have the most differences
--include-equallist identical items too

Moved and renamed files are paired instead of showing up as one missing and one new file; --only renamed lists those pairs.

6. Get the same answer on every machine

Without further switches, the command line compares with the settings saved by the Diffoniq window, such as an Ignore switch you turned on there. Add --defaults and it compares with the factory settings instead, so a script gives the same answer wherever it runs. Compare switches on the command line still apply, for example /c to ignore upper and lower case. The report header lists the options that were in effect. All switches: Command Line Arguments.

7. Schedule it, or act on it

The Task Scheduler waits for a program on its own. A complete scheduled check, including the switch that reads every file again instead of trusting stored checksums, is in Check a backup against the original folder.

To make the folders the same instead of listing the differences, /sync takes the same two paths with --mirror or --update. Without --execute it only lists what it would copy, rename or delete. Details: Folder Synchronization.

An AI coding assistant that can run commands can use the same report: have it write JSON, read the file, then act. Assistants that speak MCP can call Diffoniq as a tool directly; see Let an AI assistant compare folders, archives and files.

Good to know

Other ways to compare folders from the command line

Windows has two built-in commands that come close. In PowerShell, this lists the names found on one side only, marked <= and =>:

Compare-Object (Get-ChildItem D:\project -Recurse -Name) (Get-ChildItem E:\project-copy -Recurse -Name)

It compares names only: a file whose content changed does not appear, and a renamed file shows up as one missing and one new name. In a command prompt, robocopy with the /L switch lists what it would copy and copies nothing:

robocopy "D:\project" "E:\project-copy" /L /E

It goes by size and time stamp, so a file whose content changed while both stayed the same is not listed, and its exit code describes copying, not differences. Free tools such as WinMerge and FreeFileSync also compare folders; our comparison page shows how they differ from Diffoniq, with the date we checked.

Questions

How do I compare two folders from the command line in Windows? Run DiffoniqC.exe /report with both folders, --out and --content, as in step 1. The report lists every difference, and the exit code says whether there was one.

Can I compare two folders in PowerShell? Yes. Call DiffoniqC.exe with &, write a JSON report and read it with ConvertFrom-Json, as in step 4. Compare-Object on its own compares names, not contents.

Does it compare the contents of the files? Yes, with --content: files of the same size are compared by content. Without it, no file is read, and pairs of the same size are reported as not compared.

Can I compare a folder with a ZIP file? Yes. Either side may be an archive; the report marks the entries that lie inside it.

Can I see the result in a window instead? Start Diffoniq with the two folders and no switch, and the comparison opens in the window; see Compare two folders on Windows.

Which Windows versions does it run on? Windows 10 and 11, 64-bit.

Try it on your own two folders

Diffoniq runs on Windows 10 and 11, 64-bit. Every feature is available for 30 days before you decide.

Windows and PowerShell are trademarks of Microsoft Corporation. WinMerge and FreeFileSync are trademarks of their respective owners. Diffoniq is not affiliated with any of them.