No BSD License  

Highlights from
slocdir

from slocdir by Diffy D
Go recursively into folders to count the .m lines of code

slocdir( directoryPath )
function count = slocdir( directoryPath )
%SLOCDIR Uses the sloc function to count recursively in folders
%   Go into each subfolder to search the .m files and count the
%   lines of code with the sloc function.
%
%   Ex : slocdir('myDirectoryName')
%

%initialize the nuber of lines
count = 0;

%get the file list in that folder
list = dir(directoryPath);

%try each file in that folder and test if it's a file or a .m file
for i=1:length(list)
    
   [token,remain] = strtok(list(i).name,'.');
   if ( strcmp(remain,'.m') )
   %it's a matfile so we count his lines
       count = count + sloc(list(i).name);
   elseif (list(i).isdir && isempty(strfind(list(i).name,'.')))
   %it's a folder or a file with no extension
   %we try to go recursively into it
        try
            count = count + slocdir(strcat(directoryPath,'\\',list(i).name));
        catch
            warning( strcat( list(i).name,'file or folder skipped') );
        end
   end
end

Contact us at files@mathworks.com