A:输出到各自文件夹

This commit is contained in:
jimmy committed 2026-01-07 20:04:14 +08:00
1 parent ff67b40090
commit 4e9cec2c18
1 file changed
+13 -6
+13 -6
View File
@@ -1,8 +1,8 @@
"""
Convert all music under E:\\Music (except E:\\Music\\工具) to AAC (.m4a) using ffmpeg.
Outputs are written flat into E:\\Music\\工具\\TypeChange\\out; if two source files
or existing outputs share the same name, the last one wins and a summary of
overwrites is printed at the end.
Outputs are written under E:\\Music\\工具\\TypeChange\\out mirroring the folder
structure under SOURCE_ROOT; if two source files map to the same target path,
the last one wins and a summary of overwrites is printed at the end.
Notes:
- If the source is already `.m4a`, it is copied as-is by default (no re-encode).
@@ -20,7 +20,7 @@ from pathlib import Path
from concurrent.futures import ThreadPoolExecutor, as_completed
# Source and destination roots
SOURCE_ROOT = Path(r"E:\Music")
SOURCE_ROOT = Path(r"E:\Music\完成\专辑")
SKIP_ROOT = SOURCE_ROOT / "工具"
OUT_ROOT = Path(r"E:\Music\工具\TypeChange\out")
@@ -108,8 +108,15 @@ def iter_source_files():
def build_output_path(src: Path) -> Path:
"""Place all outputs in OUT_ROOT, using only the filename with .m4a extension."""
return OUT_ROOT / src.with_suffix(".m4a").name
"""Mirror SOURCE_ROOT folder structure under OUT_ROOT, changing extension to .m4a."""
try:
relative = src.relative_to(SOURCE_ROOT)
except ValueError:
try:
relative = src.resolve().relative_to(SOURCE_ROOT.resolve())
except (OSError, RuntimeError, ValueError):
relative = Path(src.name)
return OUT_ROOT / relative.with_suffix(".m4a")
def find_external_cover_image(src: Path) -> Path | None: