Windows Explorer - Diff two files from the context menu?
Solution 1:
Sounds like you need diff-ext!
This shell extension (diff-ext) makes it possible to launch file comparison tool for 2 or 3 files (depending on the tool) in the same directory or "save" a file(s) for later comparison. It acts as external most recent used (MRU) file list for the comparison tool.
I'm using it with KDiff3, but there are a number of other diff tools on the page it can be used with.
Solution 2:
Here's my solution to add a Right Click context menu entry to run a custom command (like calling Meld) and diff two files.
Background Simple context menu entries can be be easily added in Windows register (regedit): manually or by creating a .reg file (see example below).
The problem is that the command will be run for each file you select. There are three solutions to solve this:
- Use Shell extensions (complicated)
- Make sure your application catch the different calls (complicated)
- Use
singleinstance.exe
from context-menu-handler (simple). This program does option 2 for you. It collects arguments from the different time it is called and then pass these to the command you want. A time-out option is available to help gather calls to be collected. Follow the link for more info.
Step 1 Download singleinstance.exe from context-menu-handler (and thank the author, to whom I'm not related)
Step 2 (for file and folder comparison): Create a file with extension ".reg" with the following content (example for Meld with an Icon):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\DiffIt_Files]
@="Diff it!"
"Icon"="C:\\Program Files (x86)\\Meld\\Meld.exe"
[HKEY_CLASSES_ROOT\*\shell\DiffIt_Files\command]
@="\"c:\\Bin\\singleinstance.exe\" \"%1\" \"C:\\Program Files (x86)\\Meld\\Meld.exe\" $files --si-timeout 400"
[HKEY_CLASSES_ROOT\Folder\shell\DiffIt_Folders]
@="Diff It!"
"Icon"="C:\\Program Files (x86)\\Meld\\Meld.exe"
[HKEY_CLASSES_ROOT\Folder\shell\DiffIt_Folders\command]
@="\"c:\\Bin\\singleinstance.exe\" \"%1\" \"C:\\Program Files (x86)\\Meld\\Meld.exe\" $files --si-timeout 400"
The reg file create a context menu entry labelled "Diff It!" for all files (*
) and for Folders (Folder
). The lines containing the Icon
can be removed if you don't want an icon.
Adapt the path of the program singleinstance.exe
and the command run (here C:\Program Files (x86)\Meld\Meld.exe
. Note the escaping of the backspaces and the quotes
Step 3 Run the .reg
file. Double clicking on it might work if you are admin. Otherwise open an admin command prompt in your folder (in explorer: File>Open Command> Open Command as admin. or Alt-F-M-A
). Simply Type the name of the .reg
file to add it to the registry.
That's it.
(uninstall) You can either delete the keys manually in the registry or create a .reg
file with the following content:
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\*\shell\DiffIt_Files]
[-HKEY_CLASSES_ROOT\Folder\shell\DiffIt_Folders]
Alternative Use a software to add-edit-remove context menu entries like ContextEdit (but can't add icon easily). In this case you don't need to escape the slashes and the quotes so the command would look like this:
"c:\Bin\singleinstance.exe "%1" "C:\Program Files (x86)\Meld\Meld.exe" $files --si-timeout 400
Solution 3:
Beyond Compare and WinMerge can also do this if you enable Shell Integration during the installation.