first commit

This commit is contained in:
Soph :3 2025-12-20 12:02:36 +02:00
commit 010598a8be
15 changed files with 1128 additions and 0 deletions

View file

@ -0,0 +1,27 @@
import os
import re
ROOT = "/home/fucksophie/media/Music/axxturel loosies"
SUPPORTED_EXTS = {".mp3", ".m4a"} # add other formats as needed
def sanitize_filename(filename: str) -> str:
# Keep ASCII printable characters; replace anything else with "_"
return re.sub(r"[^\x20-\x7E]", "_", filename)
def safe_print(s: str):
# Encode with backslashreplace to avoid crashing on surrogates
print(s.encode("utf-8", errors="backslashreplace").decode("utf-8"))
for root, _, files in os.walk(ROOT):
for f in files:
ext = os.path.splitext(f)[1].lower()
if ext not in SUPPORTED_EXTS:
continue
old_path = os.path.join(root, f)
new_name = sanitize_filename(f)
new_path = os.path.join(root, new_name)
if old_path != new_path:
safe_print(f"[DRY RUN] Would rename: {old_path}{new_path}")
# To apply changes, uncomment the next line:
os.rename(old_path, new_path)