From 2ffae9ceda36c0bfe3e22a8c40436347a79263e4 Mon Sep 17 00:00:00 2001 From: Jakob Moser Date: Sun, 1 Jun 2025 14:18:29 +0200 Subject: [PATCH] Strip trailing dots, document those measures --- karaokatalog/organize/move.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/karaokatalog/organize/move.py b/karaokatalog/organize/move.py index 805978a..1977853 100644 --- a/karaokatalog/organize/move.py +++ b/karaokatalog/organize/move.py @@ -7,7 +7,11 @@ from tqdm import tqdm from karaokatalog.instructions.MoveInstruction import MoveInstruction from karaokatalog.Song import Song -FORBIDDEN_CHARACTERS = re.compile(r'[\/<>:"\\|?*]') +# Those characters are forbidden on Linux (few) or on Windows (many), so we strip them from filenames +# https://stackoverflow.com/a/31976060/ +# Apparently, trailing dots are also prohibited, so we strip those as well: +# https://lkml.iu.edu/hypermail/linux/kernel/2203.2/01877.html +FORBIDDEN_CHARACTERS = re.compile(r'[\/<>:"\\|?*]|\.$') def _get_canonical_song_dir(song: Song, variant: int = 0) -> Path: @@ -28,6 +32,9 @@ def move(songs: Sequence[Song], base_dir: Path) -> Sequence[MoveInstruction]: Create move instructions to move every song into the proper song directory within the given base_dir. """ + + # We lower case all the song directories, because Windows filesystems are often + # case-insensitive, so we have to ignore casing when finding duplicates song_dir_strs_lower = set( str(song.dir.relative_to(base_dir)).lower() for song in songs )