Fix: > 重定向相对路径应相对于输入文件目录解析

问题:用户从 C:\Users\ypshidifu 运行,执行
  D:\CloudMusic\VipSongsDownload\*.ncm>../1.wav
输出显示成功,但 D:\CloudMusic 目录空空如已,文件消失。

根因:_parse_gt_output 将相对路径解析为相对于 cwd 而非输入文件目录。
cwd is C:\Users\ypshidifu,导致 ../1.wav 解析为 C:\Users\1.wav。

修复:相对路径在 _parse_gt_output 结尾处相对于输入文件目录 (p.parent) 解析。
This commit is contained in:
ypshidifu
2026-09-17 15:16:38 +08:00
parent e24966935e
commit 8a281f584c
+3
View File
@@ -115,6 +115,9 @@ def _parse_gt_output(input_path, output_spec):
else:
# 裸格式名,仅修改扩展名
out_path = p.with_suffix("." + spec)
# 相对路径相对于输入文件的目录解析(而非 cwd),避免从不同目录运行时输出路径错误
if not out_path.is_absolute():
out_path = p.parent / out_path
ext = out_path.suffix.lower().lstrip(".")
out_fmt = _EXT_TO_FMT.get(ext, ext)
if not out_fmt: