diff --git a/modules/util.py b/modules/util.py index 052b746b3..de9bd5b9c 100644 --- a/modules/util.py +++ b/modules/util.py @@ -164,14 +164,14 @@ def get_files_from_folder(folder_path, exensions=None, name_filter=None): filenames = [] - for root, dirs, files in os.walk(folder_path): + for root, dirs, files in os.walk(folder_path, topdown=False): relative_path = os.path.relpath(root, folder_path) if relative_path == ".": relative_path = "" - for filename in files: + for filename in sorted(files): _, file_extension = os.path.splitext(filename) if (exensions == None or file_extension.lower() in exensions) and (name_filter == None or name_filter in _): path = os.path.join(relative_path, filename) filenames.append(path) - return sorted(filenames, key=lambda x: -1 if os.sep in x else 1) + return filenames