7. Opening files and directories

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 are some more detailed information and tips to use Open-dialog more efficiently.

Environment variables can be used as (part of) paths. Environment variable is expanded when it's name is put between two %:s. For example %WORKDIR%\

7.1.1. Environment variables

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

Example 2. Using environment variables

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

7.1.2. Opening archive files

If 7-Zip is installed to system WinMerge can open archive files. Opening archive files is done like other files: select archive files to Open-dialog's fields. If WinMerge recognizes archive format it opens contents of archive files to directory compare.

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

*. (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 opended with "Select..." button next to field. That dialog allows also opening filters for editing.

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 Extension

Shell extension is convenient way to select paths using Windows Explorer. Shell Extension must be first enabled from Options/System before use. When Shell Extension is enabled item "WinMerge" is added to 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 Extension 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 Extension

Selecting "Enable advanced menu" for shell extension from options allows more choices for path selection. Now WinMerge adds two menuitems to Explorer context menu: "Compare" and "Compare...". Latter is always shown and behaves like "WinMerge" item in simple menu. New "Compare" item allows selecting one item to "memory" from one location, going to another directory and then selecting second item to compare against previously memorized item.

In practice using memorized items is simple:

  1. Select first item you want to compare, open context menu and select first "Compare" 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 menuselection over first "Compare item". Now Explorer's statusbar 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.

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 file

WinMerge can read (but not write) paths from project files. Project file can be given to commandline like normal file or selected in Open-dialog. WinMerge then detects file is project file and reads paths it contains and if two paths are given opens them. If only one path is given or one of paths is invalid Open-dialog is show for user to select second path or valid paths.

Project files are simple XML files with .WinMerge extension.

7.4.1. Format

<?xml version="1.0"?>
<project>
        <paths>
                <left>c:\work\project1</left>
                <right>c:\work\project2</right>
                <filter>Visual C++ loose</filter>
                <subfolders>0</subfolders>
        </paths>
</project>

Project file has four user-editable fields:

  • <left>...</left> : Left side path to open

  • <right>...</right> : Right side path to open

  • <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 fields are required and they can be empty (<left></left>).