# Comparing Folders This page describes how to compare two folders and find out which files/folders were deleted, added or modified. [GroupDocs.Comparison](https://products.groupdocs.com/comparison/java) allows you to compare the contents of a folder (directory), process and save the result of processing. The steps for _starting the comparison_ and _configuring_ the display of the processing result in the resulting file are described below. 1. Instantiate the [CompareOptions](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.options/compareoptions) object. 1. Call the `setDirectoryCompare` method to set the `DirectoryCompare` property to `true`. 1. If needed, call the `setFolderComparisonExtension` method to change the output format to `HTML`. By default the format is `TXT`. 1. If needed, call the`setShowOnlyChanged` method to `true` to display only changed items. 2. Initialize the [Comparer](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer) object. Specify the path to the first compared folder and the `CompareOptions` object. 3. Call the [add](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer/#add-java.lang.String-com.groupdocs.comparison.options.CompareOptions-) method of the [Comparer](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer) object. Specify a path to the second folder and the `CompareOptions` object. 4. Call the [compare](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer/#compare-java.lang.String-com.groupdocs.comparison.options.CompareOptions-) method of the [Comparer](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison/comparer) object. Specify a path to save the compare results and the [CompareOptions](https://reference.groupdocs.com/comparison/java/com.groupdocs.comparison.options/compareoptions) object. The following code snippet shows how to compare the `SourceFolder` and `TargetFolder` folders: {{< tabs "example1">}} {{< tab "Java" >}} ```java // ... import com.groupdocs.comparison.Comparer; import com.groupdocs.comparison.options.CompareOptions; CompareOptions compareOptions = new CompareOptions(); compareOptions.setDirectoryCompare(true); try (Comparer comparer = new Comparer("C:\\SourceFolder\\", compareOptions)) { comparer.add("C:\\TargetFolder\\", compareOptions); comparer.compare("C:\\result.html", compareOptions); } ``` {{< /tab >}} {{< /tabs >}} The following images show the comparison result: | Result in HTML | Result in TXT | | -------------------------------------------------------------- | ------------------------------------------------------------- | | ![](https://docs.groupdocs.com/comparison/java/images/result-comparison-folders-html.png) | ![](https://docs.groupdocs.com/comparison/java/images/result-comparison-folders-txt.png) |