Skip to content

Commit

Permalink
fix: correctly sort files, display deepest dir level first (lllyasvie…
Browse files Browse the repository at this point in the history
  • Loading branch information
mashb1t authored Feb 10, 2024
1 parent 2319560 commit 98ba1d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 98ba1d5

Please sign in to comment.