Remove more special characters irrespective of filesystem support

Having colons, asterisks, question marks, pipes, and other control characters, while valid on UNIX/Linux/MacOS systems, is not good for portability. It doesn't take much away to remove this, and ensures consistent file names across multiple platforms.
This commit is contained in:
PhYrE 2024-04-24 01:39:41 +02:00
parent 5da27d32a1
commit ad9c5df7a0

View file

@ -261,9 +261,9 @@ def fix_filename(name):
if platform.system() == WINDOWS_SYSTEM:
return re.sub(r'[/\\:|<>"?*\0-\x1f]|^(AUX|COM[1-9]|CON|LPT[1-9]|NUL|PRN)(?![^.])|^\s|[\s.]$', "_", str(name), flags=re.IGNORECASE)
elif platform.system() == LINUX_SYSTEM:
return re.sub(r'[/\0]', "_", str(name))
return re.sub(r'[/\\:|<>"?*\0-\x1f]|^(AUX|COM[1-9]|CON|LPT[1-9]|NUL|PRN)(?![^.])|^\s|[\s.]$', "_", str(name), flags=re.IGNORECASE)
else: # MacOS
return re.sub(r'[/:\0]', "_", str(name))
return re.sub(r'[/\\:|<>"?*\0-\x1f]|^(AUX|COM[1-9]|CON|LPT[1-9]|NUL|PRN)(?![^.])|^\s|[\s.]$', "_", str(name), flags=re.IGNORECASE)
def fmt_seconds(secs: float) -> str: