![]() |
#1 |
Member
![]() Posts: 18
Karma: 50
Join Date: Oct 2015
Device: several
|
Scripted "Find & Replace"?
Sometimes I need to do a long list of "Find & Replace" actions (changing formatting for various image sizes, deleting unwanted formatting in css files etc.). These actions always stay the same (at least for a specific sort of EPUBs I usually have to deal with).
At the moment I use a text file as a "cheat sheet" so that I can work through the list step by step (and be able to use Copy & Paste). Thats okay, but It always takes some extra time. Is there a way to automate this, so that a list of replace actions can be done by itself? |
![]() |
![]() |
![]() |
#2 |
Unicycle Daredevil
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,944
Karma: 185432100
Join Date: Jan 2011
Location: Planet of the Pudding Brains
Device: Aura HD (R.I.P. After six years the USB socket died.) tolino shine 3
|
No idea about automating a sequence of Find&Replace actions, but it will certainly save you some time if you use the Saved Searches function of Sigil. (Ctrl+Alt+F, or in the Tools menu). You can save all the entries from your cheat sheet there and just load them from there.
|
![]() |
![]() |
![]() |
#3 |
Member
![]() Posts: 18
Karma: 50
Join Date: Oct 2015
Device: several
|
Thanks for the hint. 'Saved Searches' is a part of Sigil I may have underestimated and therefore not used until now. It's not really what I was looking for but could be a step forward.
|
![]() |
![]() |
![]() |
#4 |
Unicycle Daredevil
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,944
Karma: 185432100
Join Date: Jan 2011
Location: Planet of the Pudding Brains
Device: Aura HD (R.I.P. After six years the USB socket died.) tolino shine 3
|
Perhaps when the experts chime in, someone will be able to come up with some kind of script. That's beyond my capabilities. But Saved Searches will at least save you the trouble of doing Copy&Paste each time.
|
![]() |
![]() |
![]() |
#5 |
Klak
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 174
Karma: 150374
Join Date: Sep 2011
Location: Belgrade, Serbia
Device: many
|
I do it in Notepad++ with Pythonscript plugin
In one window is modified Python Regex Replacement script in another xhmtl file I work on. In script window you edit and save regex. In xhtml file window you run script from first window. Also very useful is Notepad++ Compare plugin because... regex. |
![]() |
![]() |
![]() |
#6 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,989
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
1)Saved search does NOT save the S&R mode or scope ![]() |
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,524
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
As theducks has mentioned, you can create a group of saved searches. Then when you highlight/load the group in the Saved Searches dialog (make sure Find & Replace widget is open), the Find/Replace operations of the Saved Searches dialog will sequentially go through each individual F&R expression in the group.
|
![]() |
![]() |
![]() |
#8 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,719
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
|
|
![]() |
![]() |
![]() |
#9 | ||
Member
![]() Posts: 18
Karma: 50
Join Date: Oct 2015
Device: several
|
Thank you, theducks and DiapDealer, for explaining the group option! I just did some quick tests and will try it out in detail very soon. That is actually close to what I was looking for (except for the need to do it separately for CSS and HTML files and keep an eye on the scope setting; I think I can live with that).
Quote:
Quote:
![]() |
||
![]() |
![]() |
![]() |
#10 | |
Klak
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 174
Karma: 150374
Join Date: Sep 2011
Location: Belgrade, Serbia
Device: many
|
Quote:
My "method" was to FIRST "regex" indesign exported single xhtml epub and THAN to split it to chapters. |
|
![]() |
![]() |
![]() |
#11 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Just to explain Groups/Saved Searches with pictures:
1. Press Ctrl+F to open Find/Replace. Change the Mode + All HTML Files to what you want use. In this case, I have "Regex" + "All HTML Files". 2. Press Tools > Saved Searches. In the Saved Searches window, you're able to create Groups of searches (groups appear Bold). Create your entire set of Find/Replaces. 3. When you're ready to run the entire batch of Find/Replaces at once: Highlight the group you want to run (#2 in the image). Then press Replace All (#3 in the image). |
![]() |
![]() |
![]() |
#12 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,584
Karma: 14328510
Join Date: Nov 2019
Device: none
|
|
![]() |
![]() |
![]() |
#13 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
Any in particular you're looking for? Last edited by Tex2002ans; 02-28-2020 at 03:25 AM. |
|
![]() |
![]() |
![]() |
#14 |
Member
![]() Posts: 18
Karma: 50
Join Date: Oct 2015
Device: several
|
Yesterday I spent the evening putting the entries from my cheat sheet into the saved searches mask. I even added a few more details and tested it thoroughly.
It now works great and will save me a lot of time in the future! I still need a checklist to edit my EPUBs because I need to do three separate runs of 'saved searches' for different kinds of files and with different Regex/Normal and AllFiles/CurrentFile settings. There are also some more things to do that can't be part of find&replace operations (like adding an HTML TOC, adding a cover, editing metadata). But these things are quickly done (unlike a long list of manual replace operations). So I'm very happy with what I learned in this thread. ![]() |
![]() |
![]() |
![]() |
#15 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
![]() There's also the Sigil Manual (User Guide). There's lots of other helpful functionality you'll run across to make your life easier. ![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Default "find" for Search/Replace regex functions | vr8ce | Editor | 14 | 02-02-2018 10:41 AM |
Missing "function mode" for editor's Search & Replace | atux | Editor | 3 | 01-17-2016 08:40 AM |
Find / Replace does not respect "down" setting | DrChiper | Editor | 24 | 01-26-2014 06:10 PM |
MS Word Find & Replace and "Smart" quotes question. | Ahu Lee | Workshop | 1 | 01-14-2013 11:02 AM |
timefmt, align="center", find replace | Kirk Vomit | Recipes | 0 | 04-11-2012 05:03 AM |