No BSD License  

Highlights from
compareRepeatedFolders

from compareRepeatedFolders by moshik hatsav
Finds all folders with the same name under a specified folder, and compares their content

compareRepeatedFolders(homeDir, ignoreFolders)
function htmlFile = compareRepeatedFolders(homeDir, ignoreFolders)
% function htmlFile = compareRepeatedFolders(homeDir, ignoreFolders)
% This method generates an HTML of the repeated folders in homeDir
% It can be seen also as an example of to use the functions:
%       findDoubles
%       compareDirectoriesEngine
%       writeComparisionHtml
%
% homeDir - the root folder where the comparison is done
% ignoreFolders - list of folder names that should be ignored 
%        ('CVS' is automatically added)
% htmlFile - the name of the HTML file created
%
% Example: compareRepeatedFolders('workdir', {'Old', 'Images'});


% prepare the ignore-list
if ~exist('ignoreFolders', 'var')
    ignoreFolders = {};
end
ignoreList = [ignoreFolders; {'CVS';'..';'.'}];

% find repeated folders
if ~exist('homeDir', 'var')
    homeDir = pwd;
end
cr = findDoubles(homeDir);  
fields = fieldnames(cr);

% prepare the results HTML
htmlStr = sprintf('<html><body><h1>Comparison Results for %s<h1><p>\n<h3>Note: a missing entry is marked with "x" different file size with "s", and different modification date with "d"</h3>\n', ...
        homeDir);

% compare each pair of folders
for i=1:length(fields)
    field = getfield(cr, fields{i});
    
    % check ignore-list
    if ~isempty(find(cellfun(@(x) strcmp(x, fields{i}), ignoreList)==1))
        continue
    end

    dir1 = field{1};
    for j=2:length(field)
        
        dir2 = field{j};
        % run the recursive folders' comparison engine
        [l1,l2,d1,d2,det]=compareDirectoriesEngine(dir1, dir2);
        
        % write comparison result to HTML
        str = writeComparisionHtml(dir1, dir2, l1, l2, d1, d2, det);
        htmlStr = sprintf('%s%s<p>\n', htmlStr, str);
    end
end

% close the results HTML
htmlStr = sprintf('%s\n</body>\n</html>\n', htmlStr);

% save the HTML file locally
htmlFile = './compare_results.html';
fid = fopen(htmlFile, 'w');
count = fwrite(fid, htmlStr); %check errors
fclose(fid);

Contact us at files@mathworks.com