View Single Post
Old 04-24-2024, 04:16 AM   #1324
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,118
Karma: 1954138
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by capink View Post
Append the following code under the run() method
Another way to do this without having to hard code the custom column name, is to append this instead to the run() method:

Code:
        db = gui.current_db
        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()}'))
            chain.set_book_var(book_id, 'save_to_disk_path', ','.join(fmt_paths))
Now, in your chain, add a second "Single Field Edit", choose the custom column from the dropdown menu and add the following template:

Code:
program:
	book_vars('save_to_disk_path')

Last edited by capink; 05-08-2024 at 08:24 AM.
capink is offline   Reply With Quote