Copy link to clipboard
Copied
I couldn't find scripts to reduce the number of character and paragraph styles, and parent pages across multiple documents without reducing unused styles I might need later which were in use in other book documents. I found a few scripts and community posts that would reduce the style or parent page by comparing only within one document at a time. What I couldn't find were scripts to iterate through a set of documents and keep styles or parents in use across all documents and remove the unused across all open documents.
So I tried my hand at authoring scripts with help from an LLM. My goals in these scripts are in context of managing book documents and combining various documents and then reducing clutter. I didn't want to figure out how to iterate through book documents or handle opening and saving a document if it wasn't open already, so I stuck to the documents that are open at the time the script runs.
I wish reducing unused styles and parents across multiple documents was a feature of InDesign.
For those who are better at scripting, here is a link to the github repo where I have my proof of concepts stored. If you believe the scripts can be improved please improve them. I haven't attempted UXP or plugins. It would be nice if these had a better visual workflow.
The general steps of each script are:
My aim in posting to the community is to help any other who might be looking for the same.
Copy link to clipboard
Copied
Why do you need this - if they're not in use then there's no issue, right? So it has 0 impact.
And they might be needed at a later date.
Just curious why you need to remove them?
Copy link to clipboard
Copied
I think "decluttering" is a valid reason, as the OP mentions.
Copy link to clipboard
Copied
Thanks for your thoughts, @TᴀW. I can see how decluttering might be useful for some workflows, especially in projects with a lot of styles and parent pages. My curiosity stems from the idea that if these elements aren’t actively causing issues, why go through the effort of removing them? It seems like it could risk removing something that might be needed later.
@Jonathan36598472odjx, could you share more about specific scenarios where having fewer styles or parent pages has improved your workflow? It might help me (and others) better understand the tangible benefits of decluttering in this way.
I'm not saying dont' 'declutter' and I'm not saying it's a bad idea - I'd just like to know more about it to better understand the request and offer a solution with more information.
Copy link to clipboard
Copied
Hi @Eugene Tyson,
To directly answer your question "Why remove them?", it's so I'm only seeing styles and parent pages I intend to use and remove redundant and orphaned styles I never intend to use again. I wanted to keep book-wide styles and parent pages so they're available within a document if needed.
The context is a set of indesign documents within a book. The documents were their own thing with their own styles and then I started conforming them to the same set of paragraph, object, character styles and master/parent pages. Indesign synchronizes by adding and updating only, so the number of styles and parent pages grew over a short amount of time. After conforming all of the documents there were orphaned styles and parent pages, enough to be cumbersome, but also unused styles and parents used in other documents that might be considered book styles and parent pages to be used as needed.
Another factor is out editorial work flow was someone else editing in word and I was importing the story into Indesign and synchronizing changes. The default word import generated 20+ paragraph and 10+ character styles for each import or instance when the author of the document wasn't using a document I had prepared for them to use.
All combined across all documents there must've been 100+ styles to sift through.
Given the presence of orphaned InDesign and Word styles and unused but necessary book-wide Indesign styles and parent pages, the script attempts to take into consideration styles in use across all open documents (a stand-in for processing book documents) and remove only unused items.
Copy link to clipboard
Copied
If you work on a PC - you could use my ID-Tasker tool.
Even in the free version you can load Styles' info from multiple documents - then sort and filter.
Paid version - can automatically process whole server full of INDD files - rename, remove, reorganise, compare, create a report so you can decide what to do, etc.
Copy link to clipboard
Copied
I remember you DM'ing me about this. It looks very cool.
Copy link to clipboard
Copied
You've overcomplicated things - not you but LLM - please check this thread:
There is no need to iterate through ALL Characters / Paragraphs - you can invoke() command from the pallet - to remove unused.
Also - there can be CharStyles used in ParaStyles used in Cell Styles.
Can't check this right now - but i think CharStyles used in GREP Styles are also not reported when checking CharStyle applied to the text.
Copy link to clipboard
Copied
I encountered this issue with the GREP setting within a paragraph style where the character style it used was only used within it and the character style was deleted. I'm unsure how to address it.
Copy link to clipboard
Copied
Please check the link - by using invoke() - you are offloading this checking to InDesign 😉
Copy link to clipboard
Copied
And it's WAY quicker than iterating through everything 😉
Copy link to clipboard
Copied
There is also one more method - the best one - copying ALL pages to a new document.
This way - you are purging EVERYTHING that is not used.
But you need to copy all pages together - using itemByRange - you can't copy them one-by-one as you'll break text threads.
Copy link to clipboard
Copied
If you really want to use your method - iterating through all Characters - it will be quicker if you would switch to iterating Text Style Ranges.
TSR is at least one Character with exactly the same formatting. So if you'll have a paragraph with first word in bold - then 200+ characters in regular - you'll have only TWO TSRs to check - instead of 200+ characters.
The same with 10x 500x character long paragraphs - styled exactly the same - you'll have ONE TSR - instead of 5000x characters.
Unfortunately, LLM's are still far behind human experience.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I didn't know about Text Style Ranges, thank you for your insight.
By @Jonathan36598472odjx
You're welcome.
Copy link to clipboard
Copied
There is one more way to do it - I'll just pitch in idea as I'm on my phone and I'm not JS guy - using everyItem() and getElements() - then sort - those two can be done as a one-liner. 3rd step - removal of duplicates - I think there is a Set()? Or a loop through all elements.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now