From 58555b109cb40e8bb7b7ad5caa52f53f8c35eed1 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Mon, 13 Nov 2023 09:53:30 -0800 Subject: [PATCH] change kobo epub filenames --- kindlecomicconverter/comic2ebook.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 7007bb1d..6068fd0a 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -19,6 +19,8 @@ # import os +import pathlib +import re import subprocess import sys from argparse import ArgumentParser @@ -673,11 +675,9 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber): filename = srcpath + tomenumber + ext else: if 'Ko' in options.profile and options.format == 'EPUB': - path = srcpath.split(os.path.sep) - path[-1] = ''.join(e for e in path[-1].split('.')[0] if e.isalnum()) + tomenumber + ext - if not path[-1].split('.')[0]: - path[-1] = 'KCCPlaceholder' + tomenumber + ext - filename = os.path.sep.join(path) + src = pathlib.Path(srcpath) + name = re.sub(r'\W+', '_', src.stem) + tomenumber + ext + filename = src.with_name(name) else: filename = os.path.splitext(srcpath)[0] + tomenumber + ext if os.path.isfile(filename):