05-29-2015, 01:50 PM | #1 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
suggestion: plugin to remove spaces
What about a plugin to remove spaces in filenames of XHTML and/or images? Or perhaps replacing them by an underscore?
Should not be too difficult I think, but I am not a Python expert. Could be very useful in case of a lot of files... |
05-30-2015, 09:40 AM | #2 |
Grand Sorcerer
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Are you thinking of an automated "everything in one fell swoop" kind of thing? I only ask because renaming files in the book browser will take care of updating all links to it.
|
05-30-2015, 12:09 PM | #3 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
How to handle these filenames:
chapter 01.html chapter_01.html in the same book? |
05-30-2015, 01:41 PM | #4 | |
Well trained by Cats
Posts: 29,817
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Select the Range: Change the names to something generic to avoid clashes Now rename those to the final sequenced names BTW the bulk renamer allows you to skip files sec01 sec02 p01 <not selected sec03 sec04 p02 <not selected |
|
05-30-2015, 01:55 PM | #5 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
|
05-30-2015, 02:13 PM | #6 |
Sigil Developer
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Actually, this is not easy as it sounds in that you must go through every link/anchor/aside/footnote, etc in every xhtml file looking for changed file names in internal links.
The code to actually do exactly this is built into Sigil in a C++ routine that performs UniversalUpdates and it is run when the epub is first loaded since the paths to the files will change due to being moved into the epub directory structure used by Sigil. In the end, it might be easier to change the builtin updates routine then to recreate all of that code in a plugin. KevinH |
05-30-2015, 06:32 PM | #7 | |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Quote:
Just kidding... |
|
05-31-2015, 10:30 PM | #8 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Just FYI, this would be five lines of code if you were making a plugin for the calibre editor (not counting the boilerplate for the plugin)
Code:
from calibre.ebooks.oeb.polish.replace import rename_files book = self.current_container fmap = {f:f.replace(' ', '_') for f in book.manifest_id_map.itervalues() if ' ' in f} if fmap: rename_files(book, fmap) and you are done. Last edited by kovidgoyal; 05-31-2015 at 11:17 PM. |
05-31-2015, 11:12 PM | #9 |
Sigil Developer
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hmm ... since all of the real work is done in rename_files for Calibre, that is very true. I think I could do something similar by extending the Sigil launcher interface and have it call the rename file code inside Sigil in a similar manner.
But I still think the easiest Sigil-based solution is to simply take care of that when the epub is first loaded. So if you are in need of a plugin quickly, doing what Kovid recommended in Calibre is probably the way to go until/if we release this feature in future version on Sigil assuming there is demand for it. Thanks Kovid! KevinH Last edited by KevinH; 06-01-2015 at 09:54 AM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
search and remove two spaces | jlocicero | Editor | 3 | 04-24-2015 03:23 PM |
CSS to indent paragraphs and remove spaces | Alda | Sigil | 7 | 06-20-2014 05:36 AM |
How to remove blank spaces? | Mamaijee | Conversion | 2 | 04-09-2013 11:20 AM |
Remove Double Spaces | PortMan | Calibre | 20 | 05-13-2012 11:43 AM |
Anyway to remove paragraph spaces in pdb files? | twister | Other formats | 3 | 03-12-2009 09:36 PM |