From 3aad79fc3071e8445566b0a2be6d2d2fa294db93 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Mon, 17 Nov 2025 13:09:27 -0800 Subject: [PATCH] fix -o in c2e for real (#1167) --- kindlecomicconverter/comic2ebook.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index b10ddd6..d725c0a 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -920,13 +920,18 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber): else: ext = '.kepub.epub' if wantedname is not None: + wanted_root, wanted_ext = os.path.splitext(wantedname) if wantedname.endswith(ext): filename = os.path.abspath(wantedname) - elif os.path.isdir(srcpath): - filename = os.path.join(os.path.abspath(options.output), os.path.basename(srcpath) + ext) + # output directory + elif not wanted_ext: + abs_path = os.path.abspath(options.output) + if not os.path.exists(abs_path): + os.mkdir(abs_path) + filename = os.path.join(os.path.abspath(options.output), Path(srcpath).stem + ext) + # output file else: - filename = os.path.join(os.path.abspath(options.output), - os.path.basename(os.path.splitext(srcpath)[0]) + ext) + filename = os.path.abspath(wanted_root) + ext elif os.path.isdir(srcpath): filename = srcpath + tomenumber + ext else: