Compare files · Two folders

How to Compare Two Folders

Comparing folders answers a different question from comparing files: which files exist only on one side, and which exist on both but differ. Each platform has a one-line answer and a visual option.

Linux and macOS: diff -rq

Recursive, quiet diff lists differing files and files present on one side only, without printing their contents. Drop -q to see the line-level changes too, and use --exclude to skip noise such as node_modules or .git.

$ diff -rq site-v1/ site-v2/ --exclude=.git
Files site-v1/index.html and site-v2/index.html differ
Only in site-v2/: sitemap.xml

rsync as a comparison tool

rsync --dry-run with -c (checksum) reports exactly what it would copy, which is a precise list of what differs by content rather than by timestamp. Nothing is transferred.

$ rsync -rcn --out-format="%n" site-v1/ site-v2/

Windows: robocopy /L and WinMerge

robocopy with /L lists what a copy would do without copying, which shows new and changed files between two folders; /E includes subfolders. For a visual comparison with per-file diffs, open both folders in WinMerge.

C:\> robocopy C:\site-v1 C:\site-v2 /L /E /NJH /NJS

Visual tools

meld (Linux, macOS via Homebrew, Windows) shows two or three folders side by side and opens any file pair as a diff. Beyond Compare is the commercial standard. In VS Code, the Compare Folders extension adds the same capability to the editor.

Comparing what changed inside a file

Once you know which files differ, compare their contents with diff -u, git diff --no-index, or by pasting both versions into the online diff checker.

Compare two texts online Paste both versions. Runs in your browser, nothing is uploaded.

FAQ

How do I compare two folders and only list filenames?

diff -rq folderA folderB on Linux and macOS; robocopy folderA folderB /L /E on Windows; rsync -rcn --out-format="%n" folderA/ folderB/ for a content-based list.

How can I tell whether two folders are identical?

diff -rq prints nothing and exits 0 when they match. On any platform, compare checksums: find . -type f -exec sha256sum {} + | sort -k2 in each folder, then diff the two lists.