mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
add tomenumber when output folder checked (#1183)
* add tomenumber when output checked * fix all cases
This commit is contained in:
@@ -916,6 +916,7 @@ def getWorkFolder(afile):
|
||||
|
||||
|
||||
def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
||||
source_path = Path(srcpath)
|
||||
if srcpath[-1] == os.path.sep:
|
||||
srcpath = srcpath[:-1]
|
||||
if 'Ko' in options.profile and options.format == 'EPUB':
|
||||
@@ -935,14 +936,19 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
||||
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)
|
||||
if source_path.is_file():
|
||||
filename = os.path.join(os.path.abspath(options.output), source_path.stem + tomenumber + ext)
|
||||
else:
|
||||
filename = os.path.join(os.path.abspath(options.output), source_path.name + tomenumber + ext)
|
||||
elif os.path.isdir(srcpath):
|
||||
filename = srcpath + tomenumber + ext
|
||||
else:
|
||||
if 'Ko' in options.profile and options.format == 'EPUB':
|
||||
src = pathlib.Path(srcpath)
|
||||
name = re.sub(r'\W+', '_', src.stem) + tomenumber + ext
|
||||
filename = src.with_name(name)
|
||||
if source_path.is_file():
|
||||
name = re.sub(r'\W+', '_', source_path.stem) + tomenumber + ext
|
||||
else:
|
||||
name = re.sub(r'\W+', '_', source_path.name) + tomenumber + ext
|
||||
filename = source_path.with_name(name)
|
||||
else:
|
||||
filename = os.path.splitext(srcpath)[0] + tomenumber + ext
|
||||
if os.path.isfile(filename):
|
||||
|
||||
Reference in New Issue
Block a user