In my dream world, all received texts for books etc. is marked up using styles from e.g MS Word. In my real world, that is unfortunately rarely the case.
I have written this script to help in the situations where a long text is formatted quite consistently, different headings are perhaps marked with bold and in a bigger font size, quotations are italic etc.
Walkthrough
I have imported a text file in InDesign, but it is not marked up with styles correctly, and there would be no reason to reuse the current styles. So I will just delete all the imported styles, but preserve the formatting, so the style panels are all clean.
Text is imported and all styles are deleted.

Placing the cursor in the text flow somewhere will let the script know what story I want it to work with. Now, activating the script, it will automatically run through all paragraphs in the story, check how they differ from the Basic Paragraph style, and create new one's where needed.
In this case, the only differing thing is the oblique font style.

Each time it has created a new style, it will also check if that style will apply to the paragraph it is checking, ensuring that all the paragraphs with the same text formatting will end up having the same paragraph style.
Furthermore it will also check all text for any local formatting within the paragraphs, so bold text will get a character style, italic text, coloured text etc. Also these will be reused, so where its applicable the same style will be used.
An example of an automatically created paragraph and character style.

Where you go from the result of a lot of AutoStyles is up to you. I prefer to create new styles, then delete the AutoStyles one by one from the panel, replacing them with the new styles.
The script will unfortunately not do all the hard work for you, but is a great tool in cleaning up messy documents!
The script
The JavaScript can be downloaded here: auto_create_p_c_styles.jsx.
You can add it to your Scripts palette and run it from there. To do that, place the file inside the "~/Library/Preferences/Adobe InDesign/Version 6.0/Scripts/Scripts Panel" folder.
Note that depending on the length of your document, the script might take a while to run.
Known bugs:
- If the first word of a paragraph is "locally formatted", the script will think that is the "general formatting" of the whole paragraph.
Comments
Sigurdur Armannsson wrote:
This is nothing but brilliant. Thanks a lot for sharing this script. I look forward to try this out in real action.
doro wrote:
Hi Thomas,
this script sounds admirable. But it doesn't work on my InDesign CS4. I tried it out on a one-column text and it kept going and going. After about two minutes I used the task manater in order to stop it. Any hints to a solution?
Best regards, doro
Silkjaer wrote:
Doro, it takes quite a while to run it as it has to check each character for differences with the paragraph style it is in etc.
Try making a 1 page document with a few paragraphs to test it out, and if it does the job as you expect, let it run overnight on a bigger document.
The script was written on a Mac for InDesign CS4 - haven't had the chance to test it out on Windows, but it should work there as well. Anyone else experiencing problems?
doro wrote:
Thomas, I tried it on one column on a two-column page, with only 3 paragraphs in it. After I broke it off I found that the script had indeed produced paragraph and character styles but I had the impression it had "hung itself", finding two minutes rather a long time for about 2.700 characters. And, yes, I'm working on Windows.
Regards, d.
Kishor Madhave wrote:
It must be very useful, never tried. 'll try.
Rose wrote:
This script could not have appeared at a better time -- I need it desperately!
But -- when I click on the .jsx link on this page, it opens the script. How do I get it into my InDesign scripts panel?
Thanks,
Rose
Silkjaer wrote:
Rose: It depends whether you are using a Mac or PC. But just right click the link and save the destination, and make sure the file it saves remains the .jsx extension. Then put it into your InDesign user scripts directory.
The user scripts location is (source):
Mac OS Users/[username]/Library/Preferences/Adobe InDesign/[version]/[language]/Scripts/Scripts Panel
Windows XP Documents and Settings\[username]\Application Data\Adobe\InDesign\[version]\[language]\Scripts\Scripts Panel
Windows Vista Users\[username]\AppData\Roaming\Adobe\InDesign\[version]\[language]\Scripts\Scripts Panel
Rose wrote:
Thomas:
Okay, I right-clicked (oh!) and downloaded the script, placed it in my scripts panel. Then I placed a few paragraphs of text from MS Word (important to "place" rather than copy and paste) and ran the script. It did seem to take a long time, but it was finally done and it worked! All the italics were called "autostyle 1", which I deleted and replaced with my own character style.
Thanks so much! This will save hours of searching and replacing italic or bold text.
I run a G5 Mac with OX 10.4.11, and Creative Suite 4.
Best regards,
Rose
Michael wrote:
Would this scrips work if I have a document with styles applied, but then local changes were made to the type? For example, say I had a paragraph style named H1 for head 1 which is defined as Myriad Pro Bold 24pt. But, then someone (or me) locally changed that text to be semibold at 36pt. Would the script identify that as locally styled and create a new style based on the H1
suzanne wrote:
does it work in CS3?
"~/Library/Preferences/Adobe InDesign/Version 6.0/Scripts/Scripts Panel"
My folder is actually
"~/Library/Preferences/Adobe InDesign/Version 5.0/Scripts/Scripts Panel"
Thanks :-)
Francine wrote:
Does this script work with InDesign CS3? I work with legal editors and all of us are still on CS3...
Ria wrote:
Thanks so much for the script!! This is going to be so handy!
(got the link through IndesignMag)
katharine shade wrote:
Very interesting! I look forward to giving it a try.
Silkjaer wrote:
Thank you for all the comments!
I am not sure about CS3 - please give it a try and report copies of any errors here, and I will try to see if I can fix it.
Michael: It would create a new paragraph style, yes. The script does not use the "Based on" feature of paragraph styles. If only a part of the new H1 paragraph was formatted (e.g. bigger font size, another weight), a new character style would be created instead.
Test it out in some small cases and you will get the picture.
absatzsetzer.de | Umsteigertips, automatische Formate, Grep, Hilfslinien und Skripte </title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" =""> <meta name="ge wrote:
...cript:pageTracker._trackPageview('/outbound/article/blog.smi.ch');">Hier gibt es Hilfe. ? Skript zum automatischen Anlegen von Zeichen- und Absatzformaten in einem Text (engl.) ? Skript zum ...
E Morris wrote:
Mange tak
HALDESIGN » Havilink – 2009. szeptember wrote:
...ed képed a flickr-en?Typediaa shared encyclopedia of typefacesInDesigning.netauto create paragraph and character stylesSpeoPixelNagy B?...
Write a comment!