I've written a function, which returns the absolute path of files after the traverse searching.
But how to return only last folder name and file name for each file (in conjunction) ?
For example, I have 3 files:
The results should be:
def find_sql(main_dir): arr =  for dirpath, subdirs, files in walk(main_dir): arr.extend(path.join(dirpath, x) for x in files if x.endswith(".sql")) return arr call_find_sql = find_sql("D:\\python\\demo_project")