We've[already covered][4]Meld from a beginner's point of view (including the tool's installation part), and we've also covered some tips/tricks that are primarily aimed at intermediate Meld users. If you remember, in the beginner's tutorial, we mentioned that Meld can be used to compare both files as well as directories. Now that we've already covered file comparison, it's time to discuss the tool's directory comparison feature.
_But before we do thatit'd be worth sharing that all the instructions and examples presented in this tutorial have been tested on Ubuntu 14.04 and the Meld version we've used is 3.14.2._
### Compare directories using Meld
To compare two directories using Meld, launch the tool and select the_Directory comparison_option.
[
![Compare directories using Meld](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-dir-comp-1.png)
][5]
Then select the directories that you want to compare:
[
![select the directories](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-sel-dir-2.png)
][6]
Once that is done, click the_Compare_button, and you'll see that Meld will compare both directories side by side, like the tool does in case of files:
Of course, these being directories, they are displayedas side-by-side trees. And as you can see in the screenshot above, the differences - whether it's a new file or a changed file - are highlighted in different colors.
According to Meld's official documentation, each file or folder that you see in the comparison area of the window has a state of its own. A state basically reveals how a particularfile/folder is different from the corresponding entry in the other directory.
The following table - taken from the tool's website - explains in details the folder comparison states in Meld.
|**State** | **Appearance** | **Meaning** |
| --- | --- | --- |
| Same | Normal font | The file/folder is the same across all compared folders. |
| Same when filtered | Italics | These files are different across folders, but once text filtersare applied, these files become identical. |
| Modified | Blue and bold | These files differ between the folders being compared. |
| New | Green and bold | This file/folder exists in this folder, but not in the others. |
| Missing | Greyed out text with a line through the middle | This file/folder doesn't exist in this folder, but does in one of the others. |
| Error | Bright red with a yellow background and bold | When comparing this file, an error occurred. The most common error causes are file permissions (i.e.,Meldwas not allowed to open the file) and filename encoding errors. |
By default, Meld shows all the contents of the folders being compared, even if they are same (meaning there's no difference between them). However, you can ask the tool to not display these files/directories by clicking the_Same_button in the toolbar - the click shoulddisable this button.
For example, here's our directory comparison when I clicked and disabled the_Same_button:
[
![Directory Comparison without same files](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-only-diff.png)
][9]
So you can see that only the differences between the two directories (new and modified files) are shown now. Similarly, if you disable the_New_button, only the modified files will be displayed. So basically, you can use these buttons to customize what kind of changes are displayed by Meld while comparing two directories.
Coming to the changes, you can hop from one change to another using the up and down arrow keys that sit above the display area in the tool's window, and to open two files for side-by-side comparison, you can either double click the name of any of the files, or click the_Compare_button that sits beside the arrows.
**Note 1**: If you observe closely, there are bars on the left and right-hand sides of the display area in Meld window. These bars basically provide "a simple coloured summary of the comparison results." For each differing file or folder, there's a small colored section in these bars. You can click any such section to directly jumpto that place in the comparison area.
**Note 2**: While you can always open files side by side and merge changes the way you want, in case you want all the changes to be merged to the corresponding file/folder (meaning you want to make the corresponding file/folder exactly same) then you can use the_Copy Left_and_Copy Right_buttons:
[
![meld copy right part](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-copy-right-left.png)
][11]
For example, select a file or folder in the left pane and click the_Copy Right_button to make the corresponding entry in the right pane exactly same.
Moving on, there's a_Filters_drop-down menu that sits just next to the_Same_,_New_, and_Modified_trio of buttons. Here you can select/deselect file types to tell Meld whether or not to showthese kind of files/folders in the display area during a directory comparison. The official documentation explains the entries in this menu as "patterns of filenames that willnotbe looked at when performing a folder comparison."
The entries in the list include backups, OS-specific metadata, version control, binaries, and media.
The aforementioned menu is also accessible by heading to_View->File Filters_. You can add new elements to this menu (as well as remove existing ones if you want) by going to_Edit->Preferences->File Filters_.
To create a new filter, you need to useshell glob patterns. Following is the list ofshell glob characters thatMeldrecognises:
| **Wildcard** | **Matches** |
| --- | --- |
| * | anything (i.e., zero or more characters) |
| ? | exactly one character |
| [abc] | any one of the listed characters |
| [!abc] | anythingexceptone of the listed characters |
| {cat,dog} | either "cat" or "dog" |
Finally, an important point worth knowing about Meld is that the case of a file's name plays an important part ascomparison is case sensitive by default. This means that, for example, the filesREADME,readmeandReadMewould all be treated by the tool as different files.
Thankfully, however, Meld also provides you a way to turn off this feature. All you have to do is to head to the_View_menu and then select the_Ignore Filename Case_option.
As you'd agree, directory comparison using Meld isn't difficult - in fact I'd say it's pretty easy. The onlyarea that might require time to learn is creating file filters, but that's not to say you should never learn it. Obviously, it all depends on what your requirement is.
Oh, and yes, you can even compare three directories using Meld, a feature that you can access by_clicking the 3-way comparison_box when you choose the directories that you want to compare. We didn't discuss the feature in this article, but definitely will in one of our future articles.