Skip to content

Commit 079578b

Browse files
REFACTOR: Use casefold for case-insensitive target directory matching in ./main_subdirs.py
1 parent 70c2229 commit 079578b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Folder Size Tagger/main_subdirs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ def delete_listed_directories(path: str) -> None:
344344
if not os.path.isdir(entry_path): # Verify if current entry is not a directory
345345
continue # Skip non-directory entries
346346

347-
if entry.lower() not in target_names: # Verify if directory name is not a Foto target
347+
normalized_entry = entry.casefold().strip() # Normalize entry name for case-insensitive comparison and trim surrounding whitespace
348+
349+
if normalized_entry not in target_names: # Verify if normalized directory name is not a Foto target
348350
continue # Skip non-target directories
349351

350352
try: # Protect recursive directory deletion
@@ -380,7 +382,9 @@ def move_video_contents_to_parent(path: str) -> None:
380382
if not os.path.isdir(source_directory_path): # Verify if current entry is not a directory
381383
continue # Skip non-directory entries
382384

383-
if entry.lower() not in target_names: # Verify if directory name is not a Video target
385+
normalized_entry = entry.casefold().strip() # Normalize entry name for case-insensitive comparison and trim surrounding whitespace
386+
387+
if normalized_entry not in target_names: # Verify if normalized directory name is not a Video target
384388
continue # Skip non-target directories
385389

386390
try: # Protect source directory content listing

0 commit comments

Comments
 (0)