1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-15 18:56:28 +00:00

fix -o in c2e for real (#1167)

This commit is contained in:
Alex Xu
2025-11-17 13:09:27 -08:00
committed by GitHub
parent 2dbc13303f
commit 3aad79fc30

View File

@@ -920,13 +920,18 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
else: else:
ext = '.kepub.epub' ext = '.kepub.epub'
if wantedname is not None: if wantedname is not None:
wanted_root, wanted_ext = os.path.splitext(wantedname)
if wantedname.endswith(ext): if wantedname.endswith(ext):
filename = os.path.abspath(wantedname) filename = os.path.abspath(wantedname)
elif os.path.isdir(srcpath): # output directory
filename = os.path.join(os.path.abspath(options.output), os.path.basename(srcpath) + ext) 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: else:
filename = os.path.join(os.path.abspath(options.output), filename = os.path.abspath(wanted_root) + ext
os.path.basename(os.path.splitext(srcpath)[0]) + ext)
elif os.path.isdir(srcpath): elif os.path.isdir(srcpath):
filename = srcpath + tomenumber + ext filename = srcpath + tomenumber + ext
else: else: