function [dwnPath]=scanFiles(initialPath, extensions,
fileHandler)
persistent total = 0;
persistent depth = 0; depth++;
initialDir = dir(initialPath);
persistent fff=cell(100,1);
printf('dir SCAN: %s ...\n', initialPath);
for idx = 1 : length(initialDir)
curDir = initialDir(idx);
curPath = strcat(curDir.folder, '\', curDir.name);
if regexp(curDir.name, "(?!(\\.\\.?)).*") * curDir.isdir
scanFiles(curPath, extensions, fileHandler);
elseif regexp(curDir.name, cstrcat("\\.(?i:)(?:",
extensions, ")$"))
total++;
file = struct("name",curDir.name,
"path",curPath,
"parent",regexp(curDir.folder,'[^\\\/]*$','match'),
"bytes",curDir.bytes);
if (!isempty(file.path))
fff(total)=file.path ;
endif
fileHandler(file);% hier beperkt tot displayen
endif
end
if!(--depth)
printf('Total number of files:%d\n', total);
dwnPath=fff;
total=0;
else
dwnPath=fff;
endif
endfunction