Thanks to everyone. It is really the best place and the best people to learn from. Here's what I followed from the discussion:
def files(root): for path, folders, files in os.walk(root): for file in files: yield path, file def copy_first_match(repository, filename, dest_dir): # aka walk_tree_copy() for path, file in files(repository): if file == filename: try: shutil.copy(os.path.join(path, file), dest_dir) sys.stdout.write("%s copied from local cache %s." % (file, repository)) except shutil.Error: sys.stdout.write("%s is available in %s. Skipping Copy!" % (file, dest_dir)) return True return False All I've added is the exception check because in case "file" is available in "dest_dir", I want to display a message. Since I'm still new and learning will be great if you let me know if this is the proper way or not. Thanks to everyone once again. It's been a very good experience understanding everyone's comments. Regards, rrs -- http://mail.python.org/mailman/listinfo/python-list