Skip to content

Commit

Permalink
Merge pull request #8 from AshMartian/loopy-sort
Browse files Browse the repository at this point in the history
Add random option
  • Loading branch information
AshMartian authored May 29, 2024
2 parents 43278ca + 0bba92d commit ff22251
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dir_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import server
import random

# Utility function for filtering files

Expand All @@ -18,6 +19,8 @@ def filter_files(directory, filter_type, filter_value, sort_by="name", sort_orde
files.sort(key=lambda x: os.path.getctime(os.path.join(directory, x)))
if sort_order == "desc":
files.reverse()
if sort_order == "random":
random.shuffle(files)

for file in files:
if filter_type == "regex" and re.match(filter_value, file):
Expand Down Expand Up @@ -47,7 +50,7 @@ def INPUT_TYPES(cls):
# Dropdown for sorting by name or date (modified/created)
"sort_by": (["name", "date_modified", "date_created"], {"default": "name"}),
# Dropdown for ascending or descending
"sort_order": (["asc", "desc"], {"default": "asc"}),
"sort_order": (["asc", "desc", "random"], {"default": "asc"}),
# External loop index
"loop_index": ("INT", {"default": 0}),
},
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-dirgir"
description = "A collection of ComfyUI directory automation utility nodes. Directory Get-It-Right adds a GUI directory browser, and a smart directory loop/iteration node that supports regex + file extension filtering + sorting methods."
version = "1.1.0"
version = "1.1.5"
license = "LICENSE"
dependencies = ["aiohttp", "tk"]

Expand Down

0 comments on commit ff22251

Please sign in to comment.