Skip to content
de

How to compare two folders on a Mac

Finder, diff -rq in Terminal and FileMerge each show part of the difference between two folders. What each one misses, and how to sync without losing files.

29 Oct 2026 · T. Krause · 7 min read

The quickest way to compare two folders on a Mac is one line in Terminal, diff -rq folder1 folder2. It lists every file that exists on only one side and every file whose contents differ, and it prints nothing for files that match. Finder has no compare command, so with Finder alone you are comparing by eye. If Xcode is installed, FileMerge gives you a graphical view. None of the three keeps two folders in sync. Finder's Merge copies one way only, and that copying is where files usually get lost.

Finder: two windows and a sort order

Open each folder in its own window and switch both to List view with Command-2. Click the Name column header so both lists sort the same way. To see more than names, Control-click any column header and turn on Size and Date Modified. Apple describes these options in the Mac User Guide.

For a flat folder with twenty files, that's enough. Past that, it falls apart. You expand subfolders one at a time on both sides and hope you scroll in step. Two files with the same name, size and date look identical in Finder even when their contents differ. Files whose names start with a dot, such as .git or .env, don't show in Finder windows unless you've changed that setting, so they never enter the comparison.

Finder's merge is no better as a sync tool. You hold Option and drag one folder onto a location that holds a folder with the same name, then click Merge. According to the Mac User Guide, Merge only appears if one folder contains items that aren't in the other. If both folders hold different versions of a file with the same name, your only options are Stop or Replace. You get no file-by-file decision and no view of which version is newer.

Terminal: diff -rq

diff ships with macOS. Point it at two folders:

diff -rq ~/Projects/website /Volumes/Backup/website

-r makes diff descend into the subfolders that both sides share. -q prints one line per difference instead of the changed lines themselves. The output looks like this:

Only in /Users/you/Projects/website: .env
Files /Users/you/Projects/website/index.html and /Volumes/Backup/website/index.html differ
Only in /Volumes/Backup/website: old-logo.png
Only in /Users/you/Projects/website: drafts

There are two kinds of line. Only in <folder>: <name> means the item exists on that side and not on the other. If the item is a folder, as drafts is here, diff reports the folder once and doesn't list what's inside it. Files A and B differ means the name exists on both sides and the contents aren't the same. Files that match produce no line at all. The exit status says the same thing in a form scripts can use, 0 for no differences, 1 for differences and anything above 1 for an error.

Unlike Finder, diff does include dotfiles. That catches a missing .env, and it also fills the list with .DS_Store noise. -x excludes names that match a shell pattern, and you can repeat it:

diff -rq -x .DS_Store -x .git ~/Projects/website /Volumes/Backup/website

What diff doesn't do is look at dates. It compares contents, so a file that differs is reported without any hint of which copy is newer. You'd check that yourself with ls -l on both paths. And diff only reports. It changes nothing on either side.

FileMerge, if you have Xcode

FileMerge is Apple's graphical diff tool, and it comes with Xcode. In Xcode it sits under Xcode > Open Developer Tool > FileMerge. From Terminal, opendiff folder1 folder2 opens the same comparison. Its man page says it compares two files or two directories, and it can merge them into a third file or directory that you choose.

On a Mac with only the Command Line Tools installed, opendiff stops with an error saying the tool requires Xcode. Xcode is a large download to get one diff window. And FileMerge's merge writes to a third location. It doesn't copy changes between the two folders you compared.

What none of them settles

Put the three side by side and the same questions stay open.

Finder sees names, sizes and dates but not contents. diff sees contents but not dates. FileMerge shows contents but needs Xcode. So none of them answers the question a sync actually needs answered, which is which version to keep.

Direction is the other gap. Finder's Merge copies one way only and offers Stop or Replace when a name clashes. diff and FileMerge copy nothing between the two folders.

Then there are deletions, and they're the trap. A file that exists only on the left might be new on the left, or it might have been deleted on the right last week. Two folders alone can't tell you which. Any tool that "fixes" the difference by copying it back undoes your delete. Any tool that deletes it to match the other side might throw away new work.

How to sync two folders without losing files

Before anything copies, decide which side wins. For a backup, the answer is easy. The working folder wins and the backup follows. Nothing gets deleted from the working folder. When you've edited on two machines, both sides can win, and a file changed on both is a conflict. "Newer wins" settles that conflict by discarding the older edit, so look at those files before you let it run.

Do a dry run every time. macOS also ships rsync, which copies one way, and -n makes it list what it would do without touching the destination:

rsync -avn --delete ~/Projects/website/ /Volumes/Backup/website/

The trailing slashes matter. With them, rsync syncs the contents of website into the other website. Without the slash on the first path, it creates website/website on the backup. Every deleting line in the output is a file that --delete would remove because it doesn't exist in the source. rsync removes those files from the destination directly. Nothing goes to the Trash.

Read the dry run the way you'd read a bank statement. Also note that rsync decides what changed from size and modification time unless you add -c for checksums. In a test for this article, a file with the same size and timestamp but different contents didn't appear in the dry run at all.

Leave deletions out of the routine sync. A one-way update that copies new and newer files and never deletes covers most days. Mirror, with deletes, only when you've read the list.

Finally, keep whatever gets replaced. If the old version of an overwritten file is still in the Trash or in a backup, a wrong choice costs you five minutes instead of the file.

Where Mirrorline fits

Mirrorline is our Mac app for comparing and syncing two folders, and it's built around those steps. It needs macOS 14 or later.

Both folders show as one aligned tree, coloured by status: identical, different, left only, right only. Folders with a difference somewhere inside show the count, so you don't expand everything by hand. You choose how strict "the same" is. Compare by name, by size, by size and date with a tolerance and a fix for one-hour daylight saving shifts, or byte for byte, which reads every file on both sides in parallel. Exclude patterns such as .git, build/* or *.log take the noise out. For any file that differs, a side-by-side text diff shows the changed lines, and binaries open in a hex view at the first differing byte.

Comparing never changes a file. You plan actions, per item or with one of three plans for the whole tree. Mirror makes one side match the other, including deletes on the target. Update copies new and newer files and never deletes. Two-Way syncs in both directions, and the newer file wins. Each plan shows in the tree as a preview first, with arrows for copies, faded items for files that would appear and strikethrough for deletions. Execute shows a summary before it runs. Replaced and deleted files go to the Trash by default, and copies are written to a temporary file first, so an interrupted copy doesn't leave half a file where the old one was.

For the case where one side isn't connected, Mirrorline saves a snapshot of a folder as a .dirsnap file, with SHA-256 checksums if you want them. Compare it against the live folder next month. With checksums, the snapshot also catches files whose contents changed while size and date stayed the same. From Terminal, open -a Mirrorline --args --left A --right B starts a comparison. Sync plans started that way are only planned, and you still press Execute in the app.

Try it on two folders where a mistake wouldn't hurt, such as a project folder and a fresh copy in which you've edited, added and deleted a few files. Compare byte for byte, plan an Update and read the preview before you press anything else. The free demo and the requirements are on the Mirrorline page.

All articles

Cookies

This site needs no cookies to work. With your consent it loads Google Analytics to count visits.

Privacy policy