From 4b48b045d276a3c033b2146c34e67e087636bdf6 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Sun, 18 Oct 2026 15:05:28 -0700 Subject: [PATCH] keep spaces, remove special characters in kepub filenames (#1465) * rename KEPUBs same as Kobo touch driver * add kepub ! note --- README.md | 2 ++ kindlecomicconverter/comic2ebook.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b44ba152..6c04f157 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,8 @@ For flatpak, Docker, and AppImage versions, refer to the wiki: https://github.co - MOBI for modern Kindles. [CBZ for KF7 Kindles](https://ebooks.stackexchange.com/questions/173/how-to-use-the-e-ink-kindle-readers-to-display-photos) like the Kindle 1/2/3/DX. CBZ for Koreader. KEPUB for Kobo (Kobo profile + EPUB = KEPUB). PDF for ReMarkable or Kindle Scribe 2025. - Where is KEPUB option? - Choosing a Kobo profile and EPUB output will output KEPUB. +- KEPUB crashes on Kobo? + - Remove any special characters like `!` from the filepath, including any intermediate **folders.** - All options have additional information in tooltips if you hover over the option. - To get the converted book onto your Kindle/Kobo, just drag and drop the mobi/kepub into the documents folder on your Kindle/Kobo via USB - Kindle panel view not working? diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 9ad6472b..a5280aaa 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -69,6 +69,9 @@ ImageFile.LOAD_TRUNCATED_IMAGES = True OS_SORT_KEY = os_sort_keygen() KF7_KINDLES = ('K1', 'K2', 'K34', 'KDX') +# https://www.mobileread.com/forums/showpost.php?p=4213802&postcount=4 +KOBO_TOUCH_DRIVER_REGEX = re.compile(r'[\/\\\?%\*:;\|\"\'><\$!]') + def main(argv=None): global options parser = makeParser() @@ -1101,9 +1104,9 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber): else: if 'Ko' in options.profile and options.format == 'EPUB': if source_path.is_file(): - name = re.sub(r'\W+', '_', source_path.stem) + tomenumber + ext + name = KOBO_TOUCH_DRIVER_REGEX.sub('_', source_path.stem) + tomenumber + ext else: - name = re.sub(r'\W+', '_', source_path.name) + tomenumber + ext + name = KOBO_TOUCH_DRIVER_REGEX.sub('_', source_path.name) + tomenumber + ext filename = source_path.with_name(name) else: filename = os.path.splitext(srcpath)[0] + tomenumber + ext