Task

Walk a given directory tree and print files matching a given pattern.


Note: This task is for recursive methods.   These tasks should read an entire directory tree, not a single directory.


Note: Please be careful when running any code examples found here.



Related task

   Walk a directory/Non-recursively   (read a single directory). 


function walk_a_directory_recursively(d, pattern)
	f = dir(fullfile(d,pattern));
	for k = 1:length(f)
		fprintf('%s\n',fullfile(d,f(k).name));
	end;
 
	f = dir(d);
	n = find([f.isdir]);	
	for k=n(:)'
		if any(f(k).name~='.') 
			walk_a_directory_recursively(fullfile(d,f(k).name), pattern);
		end;
	end;
end; 