Quote:
Originally Posted by Dzib
Works fine, thanks
|
Append the following code under the run() method:
Code:
col_name = '#custompath'
db = gui.current_db
id_path_map = {}
for book_id in chain.scope().get_book_ids():
fmt_paths = []
fname = chain.evaluate_template(opts.template, book_id)
if single_dir:
fname = os.path.basename(fname)
if opts.formats == 'all':
formats = db.formats(book_id, index_is_id=True)
else:
formats = settings['formats']
for fmt in [fmt.strip().lower() for fmt in formats.split(',')]:
fmt_paths.append(os.path.join(path, f'{fname}.{fmt.lower()}'))
id_path_map[book_id] = ','.join(fmt_paths)
db.new_api.set_field(col_name, id_path_map)
Note: If you save more than one format per book, the above code will add them all to the custom column as comma separated list.
Quote:
Originally Posted by Dzib
Another question, not related : if I make a new chain with open with action, how to use the serie in the template but only if it's not null ?
I've tried with an if else statement but it's not working
|
Consult the
template language manual under the "Conditionally including text" section.