fix: correctly sort files, display deepest dir level first

This commit is contained in:
Manuel Schmid 2024-01-07 14:28:12 +01:00
parent 176faf6f34
commit 74eec84a61
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B
1 changed files with 3 additions and 3 deletions

View File

@ -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