Added a new function that is a generator to scan directories.