7. Opening Files and Folders

WinMerge allows selecting/opening paths in several ways. Using Open-dialog is just one of them.

7.1. Open-Dialog

Basic use of Open-dialog is described in Quick start. Here is some more detailed information and tips about how to use Open-dialog more efficiently.

7.1.1. Environment variables

Environment variables can be used as (part of) paths. An environment variable is expanded when its name is put between two %:s.

Example 2. Using environment variables

If an environment variable named WORKDIR contains the path c:\workfiles then %WORKDIR%\project1 is expanded to path c:\workfiles\project1 .

7.1.2. Opening archive files

Archive file support requires 7-Zip plugin to be installed. See Installing instructions.

Opening two archive files is similar to normal files: select two archive files to Open-dialog's "Left" and "Right" fields. If WinMerge recognizes the archive format, it opens the contents of the archive files to folder compare.

Folder Compare chapter describes how to work with archive files. If the archive file contains subfolders Original/ and Altered/ it must be opened by selecting same filename to both sides in Open-dialog or command line. Then WinMerge can compare contents of those two subfolders.

[Tip] Tip

When dragging an archive file to WinMerge window, press Shift when dropping the file and WinMerge will automatically copy the same filename to both sides and open the archive file.

7.1.3. Filter selection

Third edit field in Open dialog is for filter. This field can contain list of file extensions to include or file filter name.

Extensions must always be in format *.extension. So file extension list cannot be used for more advanced selecting, file filters are there for it. Different extensions can be separated by spaces, commas, colons or semicolons.

Example 3. Extension list

*.h;*.cpp *.txt,*.ini
[Tip] Tip

*. (star, dot and no extension) selects files without any extension, for example "README".

Field can also contain file filter name. Easiest way to select file filter is using Filters-dialog which can be opened with "Select..." button next to field. That dialog allows also creating, editing and deleting of filter files.

[Note] Note

If filter cannot be found by name or extension list is not valid WinMerge selects all files (i.e. uses *.* as extension list).

7.2. Shell Integration

The Shell Integration is a convenient way to select the paths using Windows Explorer. Installer enables Shell Integration if chosen so. Shell Integration can be enabled or disabled from Options/System. When the Shell Integration is enabled item WinMerge is added to the Explorer context menu (click right mouse button over file or folder in Explorer).

WinMerge accepts one or two paths. When one path is selected through Shell Integration WinMerge places it as "Left" path and open Open-dialog for user to select "Right" path. Also if two paths are selected but another path couldn't be opened for reason or another WinMerge shows Open-dialog for selecting valid paths.

7.2.1. Advanced Shell Integration

Selecting "Enable advanced menu" for Shell Integration from options adds more choices for path selection. Now WinMerge adds two menu items to Explorer context menu: "Compare To" and "Compare...". Compare To selects path as first ("Left") path. When one path is already selected (memorized) WinMerge adds items "Compare" and 'Re-select First" to context menu. Now Compare selects path as "Right" path and compares it with previously selected path. Re-select First allows re-selecting first path. Handy when wrong item got accidentally selected as first path.

Sounds complicated, but luckily it is not - in practice:

  1. Select first item you want to compare, open context menu and select first "Compare To" item. Path is now in memory.
  2. Browse to location of second item you want to compare and select it. Open context menu and move menu selection over first "Compare" item. Now Explorer's status bar shows memorized path to which you are comparing newly selected path.

After memorized path is used for compare it is forgotten. So user cannot select one item to memorize and then compare it against several paths.

[Tip] Tip

Take benefit of Open dialog's MRU lists! Compare... Item selects path as"Left" path and opens Open-dialog. Now you can select "Right" path from MRU list. This is very handy when you need to compare one file/folder against several files/folders.

7.2.2. Including Subfolders

Shell Integration by default does not include subfolders into comparison. This default behavior can be changed using Include Subfolders by Default option in System options. Default behavior can be also changed by holding down Control -key while selecting Compare-item from the Explorer context menu.

7.3. Drag and Drop

One or two paths can be drag and dropped to WinMerge window from Windows Explorer, Desktop or whatever source Windows allows dragging paths from. WinMerge does not include subfolders in compare. Subfolders can be included by pressing Control-key while dropping paths.

Another useful key when dropping paths is Shift. When there is only one path dropped and Shift is pressed that same path is opened to both sides.

7.4. Project Files

Project files allow fast and easy opening of commonly used paths (and filter). The user can easily save currently open paths as project file for later use.

7.4.1. Opening Project File

Project file can be given to command line like normal file or opened from File->Open Project... WinMerge reads paths from project file and if two paths are given opens them. If only one path is given or one of paths is invalid, the Open-dialog is shown for user to select the second path or valid paths.

Project file can be selected also in Open dialog. There are couple of things to remember:

  • If two project files are selected, project files themselves are compared.
  • If project file is selected as left-side file, and right-side file is empty, project file is opened like using File->Open Project... dialog.
  • If project file is selected as left-side file and any other file as right-side file, contents of project file and another file are compared.

7.4.2. Editing and Saving Project File

Project files can be edited and saved using Project File -dialog that can be opened from File->Save Project... When opened, the dialog is initialized with values from the current compare. Values can be edited and saved to the project file with Save... button. One can also load existing project file with Open... button.

7.4.3. Format

Project files are simple XML files with .WinMerge extension.

<?xml version='1.0' encoding='UTF-8'?>
<project>
	<paths>
		<left>c:\work\project1</left>
		<left-readonly>1</left-readonly>
		<right>c:\work\project2</right>
		<right-readonly>0</right-readonly>
		<filter>Visual C++ loose</filter>
		<subfolders>0</subfolders>
	</paths>
</project>

The project file has six fields:

  • <left>...</left> : Left side path to open
  • <left-readonly>...</left-readonly> : 1 if left side path is opened as readonly, 0 to open normally
  • <right>...</right> : Right side path to open
  • <left-readonly>...</left-readonly> : 1 if right side path is opened as readonly, 0 to open normally.
  • <filter>...</filter> : file filter name or list of extensions
  • <subfolders>...</subfolders> : 0 if subfolders are not included and 1 if they are included

None of the fields are required and they can be empty (<left></left>).