i wanted to share this indesign script i wrote. I would be happy if people were using it and perhaps give me feedback. The script finds and replacesapplies conditional combinations(!) of paragraph styles comfortably in almost any kind of selection
- In the stories of the selected textframes find each paragraph with style "Headline1" if it is followed by "Subhead1" and change it to "Headline2" followed by "Subhead 2".
Find the newest version lower down below.
The script has a lot of options and use cases and gotten better over the years, you can use it on almost any kind if nested selection of groups and anchored opjects now too.
If you give me feedback, perhaps supply me with some example-document with the situation, where the error occured. But a description will work too.
(It's originally modeled after "Fix paragraph style combinations" by Thomas Silkjær, 2009, and its now WAY more advanced -
Edit April 2022: removed source code of paragraphStyleChanger.jsx Version 1.11 (from March2017) from this post to clean up thread, re-attached .1.12-txt-file to this post for continuity. See newest version 2.75 down below.
Nice! It even works perfect with my old work-horse InDesign CS4 -- you have to remove the line "#target indesign" for that, but that's all.
(As copying-and-pasting into a blank document may be a bit cumbersome for less experienced script users, I'd recommend to also add a download link.)
Thank you both very much for testing it! I removed the target-line as per your advices. And i am happy that it runs in all those version. You're right with the download...:
EDIT February 2022: See below for latest source code of "paragraphStyleChanger". Version 2 had lots of improvements.
>> What did you change between 1.1 and 1.11 ?
I changed the way the "find/findNext style from current selection"-setting preselects styles in the dropdowns. You now have to select two paragraphs if you want to preselect the current AND the 'next' paragraph style. If selection is insertion point, it will only load the current style into the find-field and leave the followed-by field as ANY-STYLE. (That also fixed a bug if you selected a textframe with only one paragraph).
unfortunately one cannot mark your post as helpful. But it is!
What did you change between 1.1 and 1.11 ?
I've seen 1.1 posted here:
Could not test it yet but had a quick look at its functionality and the UI.
Removing #target indesign is a good idea.
Wanted to run it from the ESTK first where InDesign CS6 8.1.0 was connected as target and was waiting in the background.
The result after starting the script was: InDesign CC 9.3.0 on the same machine was triggered and started up.
The first thing I did was removing the target instruction.
Note: I have several versions of InDesign installed side by side. CS6, CC, CC 2014.2, CC 2015.4.1 and CC 2017. Together with some prerelease versions. All on OSX 10.10.5.
February 2022: Someone contacted me about this script. I never published my last version of it back in 2018. The last version is "paragraphStyleChanger2-73,jsx" from May 2018. I still use it up to this very day in my job in CC2022 as editorial designer. It has some bugs left – like: sometimes it stops reacting to selection changes in indesign. Closing and restarting the script helps and doesn't hurt. I will never get so deep into programming again to be able to fix it. If you don't trust this download link of the source code from my google Drive take the source code below for copy&pasting.
There were a lot of great changes and improvements in 2.73. Make sure to read the description at the start of the source code below.
Hi Stephan. Thanks a lot for your work. I've been using version 1.11 of the script for a long time. I've downloaded version 2 and i'm happy with the option of "catching" a selection of two consecutive paragraphs. Great!
Thank you for writing! I am happy when it is found and used.
One more thing, Stephan. I have found that the script changes consecutive paragraphs inside a table if the text cursor is inside a table. But if no text frame is selected the script ignores the text inside the tables. Is it possible for the script to catch paragraphs inside a table? Thanks in advance!
yes, the script used to work on a selected table, or any range of table cells. It also works on a selected textrange or selection of paragraphs inside a cell. I checked if paragraphStyleChanger still works that way and found that for some reason v2.73 no longer works on a fully selected table. I ended up upgrading the script to version 2.75 which now works with a lot more cases of NESTED objects – tables inside of tables, anchored textframes inside of stories, ... inside of groups ... or most other wild combinations. Try if it works for you. See below.
v.2.75 - bugfixes for working with more cases of nested objects, anchored textframes, tables in tables, and textpaths in polygons
or rename attached .txt-file to .jsx.