python-snippets/utils/file_utils.py
2024-07-17 22:30:12 +01:00

22 lines
587 B
Python

import os
def search_path(path, substring):
"""
given a search substring, retrieve all the files in the Store
that have that substring in them.
Args:
path (string): path to search
substring (string): the string to be matched against
Returns:
list: a pythonized list of all the files in which the search
substring is contained.
"""
matched_files = [matched_file
for matched_file in os.listdir(path)
if substring in matched_file]
return matched_files