python-snippets/utils/file_utils.py

22 lines
587 B
Python
Raw Normal View History

2024-07-17 21:30:12 +00:00
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