From df05678ddcda249010cf484e8b0cbfe1f8501e4a Mon Sep 17 00:00:00 2001 From: Starnakin Date: Thu, 22 May 2025 17:52:04 +0200 Subject: [PATCH] fix: sort file by name --- src/path.py | 10 ++++++++-- tools/copy.py | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/path.py b/src/path.py index 630c4b1..581e65b 100644 --- a/src/path.py +++ b/src/path.py @@ -42,7 +42,10 @@ class Path(): def get_dirs(self) -> list[Path]: dirs: list[Path] = [] - for element in os.listdir(self.get_absolute_path()): + elements = os.listdir(self.get_absolute_path()) + elements.sort() + elements.reverse() + for element in elements: path: Path = Path(self._absolute_path, element) if (os.path.isdir(path.get_absolute_path())): dirs.append(path) @@ -50,7 +53,10 @@ class Path(): def get_files(self) -> list[Path]: files: list[Path] = [] - for element in os.listdir(self.get_absolute_path()): + elements = os.listdir(self.get_absolute_path()) + elements.sort() + elements.reverse() + for element in elements: path: Path = Path(self._absolute_path, element) if (os.path.isfile(path.get_absolute_path())): files.append(path) diff --git a/tools/copy.py b/tools/copy.py index 7cdcb22..53e799a 100644 --- a/tools/copy.py +++ b/tools/copy.py @@ -34,6 +34,7 @@ def main(): copy_info: dict[str, str] = get_copy_info(copy_path) files: list[str] = [os.path.join(input_folder, f) for f in os.listdir(input_folder)] files = [f for f in files if os.path.isfile(f) and f.endswith(".NEF")] + files.sort() with Bar("copying...", max=len(files)) as bar: for file in files: with open(file, 'rb') as f: