Quote:
Originally Posted by edojan
@kovidgoyal your help would be greatly appreciated. I have been hitting the wall for a very long time -  but the issue remains. I wonder if it would be possible to implement a feature - e.g. via tweaks to keep the destination file names exactly the same as the source (i.e. Calibre)? 
|
Quote:
Originally Posted by kovidgoyal
You were given a template that does it by chaley, not sure what more you want. It should be a trivial change in the template to both add an author folder and remove the file extension, or whatever else floats your boat. Good luck.
|
In addition, it would most likely be me that would implement such a feature, which I'm not going to do. I'm thinking of making a template function to return the path segments rather than something so specific, which would permit the user to construct the path however the person wishes.
Quote:
Originally Posted by edojan
Also, the above code produces double extension such as
Code:
Istsielieniie dukhovnykh boliez - Zhan-Klod Larshie.epub.epub
|
It doesn't for me. I suspect that something got changed when you entered the template.
Quote:
Originally Posted by edojan
I am sorry - I spaced out for a min  You are correct. Of course, the intent was to produce the identical file name on the device equal to one in the Calibre library - which your code did. Is there a way to modify the code to place the file in the {Author} folder? This would really solve the issue for me  .
|
This template adds the author used by calibre in the library, and is slightly more robust across operating systems.
Code:
python:
def evaluate(book, context):
import os
from calibre.library import current_library_path
fmt_metadata = book.get('format_metadata')
if fmt_metadata:
for v in fmt_metadata.values():
# A calibre format name is three section, author, title, format.extension
# We want to return author/format without the extension
p = v['path']
r,f = os.path.split(p)
format = os.path.splitext(f)[0]
r,title = os.path.split(r)
r,author = os.path.split(r)
return '/'.join((author, format))
else:
return 'title - author'
Using the above template, the book

saved in the library at
Code:
"C:\CBH_Data\calibre.git\Library.test_small\A B\Unknown2 (foo) (1313)\Unknown2 (foo) - A B.epub"
generates the path
Code:
A B/Unknown2 (foo) - A B
On my Kobo Libra 2 the book is stored with no doubled extension at