Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 10-21-2015, 06:18 PM   #1
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Help with Container rename & replace_links methods

I'm trying to figure out how to use the above. Please can you give some guidance how the 2 methods should be used together e.g.

If I have container of an epub and I want to change the name of

oldname = 'text/chap1.html' --> newname = 'text/chap1b.html'

oldname contains links to other files and is also linked to by other files.

I think I need to start with

container.rename(oldname, newname)

and I think I need to use a loop round (opf + ncx + spine items) with some combination of

repl = LinkRebaser(container, oldname, newname)
container.replace_links(name, repl)
container.dirty(name)

to correct any links related to oldname ... but as this isn't working I'm obviously misunderstanding somewhere. Please can you put me on track?

By 'not working' I mean, the file is renamed but I'm failing to get the opf file to update.

Followup question ... if the file to be renamed was an image, rather than html, how would the process differ?

Last edited by jackie_w; 10-21-2015 at 06:23 PM.
jackie_w is offline   Reply With Quote
Old 10-21-2015, 11:00 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
from calibre.ebooks.oeb.polish.replace import rename_files

rename_files(container, {oldname1:newname1, oldname2:newname2})

That's all you need to do for any kind of file.

Just be careful not to rename files that must not be renamed, such as files in the META-INF directory.
kovidgoyal is offline   Reply With Quote
Old 10-22-2015, 08:00 AM   #3
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
I should have known I was over-complicating it!

I was obviously looking in the wrong Class for a suitable method.
jackie_w is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Original "Simple" debricking methods for K5-Touch, K4-Mini, & K3-Keyboard geekmaster Kindle Developer's Corner 1383 06-24-2022 05:03 AM
'Tag & Rename' For Metatags???? antd Reading and Management 0 06-10-2012 12:28 PM
Two feature requests. (rename + s&r enhancement) Perkin Sigil 7 09-10-2010 03:03 PM
Apple Aggregator Policies & Methods Fabe General Discussions 3 04-20-2010 01:47 PM
IDPF - New digital book standard released: OEBPS (XML format) & OCF (container) CommanderROR News 13 11-04-2006 08:49 AM


All times are GMT -4. The time now is 09:42 PM.


MobileRead.com is a privately owned, operated and funded community.