I have 1000+ ePub books on my Ubuntu machine.(I know they are not exactly archives, but I can open them using Archive Manager). I want to delete a file stylesheet.css from all the ePubs. I don't wanna edit each epub individually. Is there any way to accomplish this?
Asked
Active
Viewed 188 times
0
-
Since an EPUB file is simply a ZIP file, you could use e.g. Python and remove the style sheet from the archive (see [this question](http://stackoverflow.com/questions/513788/delete-file-from-zipfile-with-the-zipfile-module) for details). But why would you want to do that in the first place? – Jens Mar 02 '16 at 06:12
-
In calibre ebook viewer, I can't change font because of the stylesheet contained in the ePub file, that's why I have to remove the stylesheet from ebooks.. – mayank budhwani Mar 02 '16 at 09:12
-
After some hunting around, I found a way.. See answer below.. – mayank budhwani Mar 02 '16 at 09:12
-
There are better epub viewers than Calibre, you know... – Jens Mar 02 '16 at 12:26
1 Answers
0
Run this script in the directory containing epubs:
for f in *.epub; do zip -d "$f" stylesheet.css; done
zip has to be installed for this. It can be installed using
apt-get install zip

mayank budhwani
- 194
- 9
-
This works if and only if the EPUB file has only one CSS file, and it is named "stylesheet.css". Not all EPUB files are like that. – Alberto Pettarin Apr 05 '16 at 16:02
-
@AlbertoPettarin the code can be modified to delete all css files having any name by replacing stylesheet.css with *.css – mayank budhwani Apr 06 '16 at 02:54
-
Note that a CSS file is not required to have a name ending in `.css`, although it is a common convention. Anyway, this and the previous comments were written for the benefit of people landing here in search for the answer to the "how to remove CSS rules from an EPUB file" question, who might be led to think that removing "stylesheet.css" accomplishes that. In other words, your answer fulfils your specific question, but it is not a general solution to the underlying problem "how to remove CSS rules from an EPUB file". – Alberto Pettarin Apr 06 '16 at 15:23