View Single Post
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,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
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