diff --git a/README.md b/README.md index 8b85f33..e69f3fb 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ Variables marked with * are required for running MD Notes properly, the others a 1. When set to `True` tag search only search with YMF. 2. When set to `False` tags will be searched the whole MD note. +* **Recursive Search** (`recursive_search`): Defines if the search should searching `path_to_notes` and it's subfolder or just the root folder. + * **Exact Match** (`exact_match`): Defines if the search should match the exact search term (`True`) or the string (`False`) in markdown notes. **Note:** When exact match is set to `True` it is possible to enhance the search term with wildcards diff --git a/src/MyNotes.py b/src/MyNotes.py index 86086ea..30dc72a 100644 --- a/src/MyNotes.py +++ b/src/MyNotes.py @@ -56,6 +56,7 @@ def __init__(self): raise ModuleNotFoundError("Python version 3.7.0 or higher required!") self.extension = self.__buildNotesExtension() self.path = self.__buildNotesPath() + self.recursive_search = Tools.getEnvBool('recursive_search') self.default_template = os.getenv('default_template') self.template_tag = os.getenv('template_tag') self.url_scheme = os.getenv('url_scheme') @@ -380,8 +381,13 @@ def getFilesListSorted(self, reverse: bool = True) -> list: err = 0 file_list = list() try: - file_list = os.listdir(self.path) - # file_list = os.walk(self.path) + if self.recursive_search: + for root, _, files in os.walk(self.path): + for file in files: + file_list.append(os.path.join(root, file)) + else: + file_list = os.listdir(self.path) + except OSError as e: err = e.errno pass