GroupDocs.Comparison allows you to compare the contents of a folder (directory), process and save the result of processing.
The following code snippet shows how to compare the two folders:
'use strict';// Import the GroupDocs Comparison Node.js SDK
constgroupdocs=require('@groupdocs/groupdocs.comparison');// Create a CompareOptions instance to configure comparison settings
constcompareOptions=newgroupdocs.CompareOptions();// Enable directory comparison mode
compareOptions.setDirectoryCompare(true);// Initialize the Comparer with the source folder and the configured options
constcomparer=newgroupdocs.Comparer('sample-files/SourceFolder',compareOptions);// Add the target folder to compare against
comparer.add('sample-files/TargetFolder',compareOptions);// Run the comparison for directories and generate the result as an HTML file
comparer.compareDirectory('result.html',compareOptions);// Terminate the process with a success exit code
process.exit(0);
This example creates a CompareOptions object and enables directory comparison mode by setting setDirectoryCompare(true). It initializes the Comparer with the source folder path and the options, adds the target folder using add() with the same options, and then calls compareDirectory() instead of compare() to perform folder comparison. The result is saved as an HTML file that shows which files were added, deleted, or modified between the two folders.
The following images show the comparison result:
Result in HTML
Result in TXT
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.