No BSD License  

Highlights from
Find repeated m-file names

from Find repeated m-file names by Dimitri Shvorob
(in a directory tree)

namesakes(path)
function[list] = namesakes(path)
% NAMESAKES Find repeated m-file names in a directory tree
% Inputs  : path, string
% Outputs : list, cell array of strings with paths of selected files
% Notes   : Search relies on RDIR (available from FEX) and ignores namesake class methods
% Example : list = namesakes('C:\Matlab');  char(list)
% Dimitri Shvorob, dimitri.shvorob@gmail.com, 8/8/08

if exist(path,'dir') ~= 7
   error('??? Path %s not found.',path)
end

f = rdir([path filesep '**' filesep '*.m']);
f = struct2cell(f)';
f = f(:,1);

m = cellfun(@moniker,f,'UniformOutput',false);
g = sortrows([f m],2);

list = {};
if ~isempty(g)
    for i = 2:length(g)
       if strcmp(g(i,2),g(i-1,2))
          list = [list; g(i-1:i,1)];       %#ok
       end
    end
end

end

function[m] = moniker(s)  % m-file name preceded by class name, if any
j = max(strfind(s,filesep))+ 1;
f = s(j:end);
j = strfind(s,'@');
if ~isempty(j)
    s = s(j:end);
    k = min(strfind(s,filesep));
    m = [s(1:k) f];                              %#ok
else
    m = f;                                       %#ok
end
end

Contact us at files@mathworks.com