Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 08-28-2018, 09:50 AM   #1
Kiruhdu
Enthusiast
Kiruhdu began at the beginning.
 
Kiruhdu's Avatar
 
Posts: 25
Karma: 10
Join Date: Mar 2014
Device: Pocket Book Touch Lux 4
Question Batch-Processing of CSS in epub

Hi there

I often have to work over a whole series of calibre-created epubs where I do the same corrections in the CSS over and over...

Now I want to ask if there is any way to do this in a batch or something similar?

Much thanks in advance for your help!
Kiruhdu is offline   Reply With Quote
Old 08-28-2018, 11:52 AM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,637
Karma: 5433388
Join Date: Nov 2009
Device: many
That all depends on what you are trying to do exactly. Both Sigil and Calibre allow regular expression based search and replace which can be used to automate the tasks. Both Sigil and Calibre allow plugins that can auto process any loaded epub. But creating a Sigil or Calibre plugin requires some knowledge of python and some knowledge of the plugin interface mechanism. Sigil's is perhaps easier to learn by example and is limited to the contents of the ebook, whereas Calibre's plugins have a more complicated interface but can do more.

That said, if you know some python or how to use regular expressions (or .bat files and have a tool you use) and your books are all epubs, you should be able to write a script to open (unzip) each epub in a folder, process it as desired, re zip up the revised epub, and repeat.

So it is hard to help without some idea of the changes needed in detail.
KevinH is offline   Reply With Quote
Old 08-28-2018, 12:01 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,547
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I was looking at ways to add an "All CSS Files" option to our F&R parameters, but my head very quickly spun when trying to grasp the logic of that code.

The only way to currently do regex processing on css files is one file at a time with "Current File" selected. I think many would like an "All CSS Files option." But from what I saw, it looked like adding that option would require a minor overhaul of the existing F&R codebase.

But even that's not going to help the OP "batch process" css from many individual epubs. Sigil is really not geared toward batch processing at all.
DiapDealer is offline   Reply With Quote
Old 08-28-2018, 01:47 PM   #4
najgori
Klak
najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'
 
najgori's Avatar
 
Posts: 174
Karma: 150374
Join Date: Sep 2011
Location: Belgrade, Serbia
Device: many
i open css with notepad++ and run multiple regex search&replace with notepad++ python script plugin.
for sure it can be done with sigils plugin engine but i am used to do it this way.
notepad++ python script plugin comes with couple sample plugins.

edit: it is just one epub with multiple changes. i don't know how to do the same thing on multiple epubs

Last edited by najgori; 08-28-2018 at 02:29 PM.
najgori is offline   Reply With Quote
Old 08-29-2018, 09:16 AM   #5
elibrarian
Imperfect Perfectionist
elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.elibrarian ought to be getting tired of karma fortunes by now.
 
elibrarian's Avatar
 
Posts: 460
Karma: 724664
Join Date: Dec 2011
Location: Ølstykke, Denmark
Device: none
Quote:
Originally Posted by Kiruhdu View Post
I often have to work over a whole series of calibre-created epubs where I do the same corrections in the CSS over and over...

Now I want to ask if there is any way to do this in a batch or something similar
As I see it, that would require a tool that's able to search & replace inside an epub (or a zip-archive, which is more or less the same thing), without touching anything else in the archive.

The only tool I know of that's able to do that (in Windows anyway), is PowerGrep https://www.powergrep.com/, but it comes with both a learning curve and a price tag, and both sort of steep …

I'm told that there exists a Linux commandline grep-tool to search and (maybe?) replace in zip files - zipgrep. I've not used Linux lately, but you might be able to use it in a shell script or something.

As allways: FWIW.

Regards,

Kim
elibrarian is offline   Reply With Quote
Old 08-29-2018, 11:06 AM   #6
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,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use the transform styles tool in the calibre conversion dialog -- it allows you to create rules to manipulate CSS and can work in bulk. The tool is also present int he calibre editor, but that works one book at a time.

Last edited by kovidgoyal; 08-29-2018 at 09:58 PM.
kovidgoyal is offline   Reply With Quote
Old 08-29-2018, 07:32 PM   #7
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
You can also just use a template css file that has all of your standard css that you want.

Then just use whatever form of search & replace, powergrep, etc. to change the tags within the html documents to match what you already have in the css.
Turtle91 is offline   Reply With Quote
Old 08-31-2018, 10:44 AM   #8
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Since epubs are zip files, use a command line unzipper to unzip all to a folder.
Now you can use whatever S&R app or text editor you like that has a batch mode to edit the css and xhtml of all the files of interest at once. Even sed, perl, whatever.

Rezip-- I know that you need to zip without compressing the mimetype file, there are ways to do that, e.g. epubpack.

Last edited by AlanHK; 08-31-2018 at 11:19 AM.
AlanHK is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch processing with kindlegen Blunaigel Kindle Formats 28 01-25-2019 10:01 AM
Is there a way to batch edit multiple epub css? stevenam ePub 10 12-30-2016 03:40 AM
In an ePub reader, what are the rules for processing styles/CSS? mattcurtis ePub 1 04-05-2013 11:11 AM
Tag editor with batch processing semenoof General Discussions 0 01-17-2013 03:12 AM
Batch processing of PDB files? Asterra iRex 6 12-04-2007 01:10 PM


All times are GMT -4. The time now is 12:19 AM.


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