Skip to main content
Inspiring
July 8, 2014
Answered

Script to replace small caps that are typed as capital letters with non-capital letters (A => a, B => b, etc...)

  • July 8, 2014
  • 4 replies
  • 1410 views

I'm looking for a way to replace small caps that are typed as capitals by their normal equivalent.

I've got a text that contains a lot of names which should all be set in small caps.

In fact they are, but because capital letters are used for first letters they don't scale.

Short: I would like to be able to look for A, B, C... (in small caps) and replace them with (a, b, c...) in small caps in one go.

(compare two arrays?? -> is this possible in indesign scripting)

This topic has been closed for replies.
Correct answer Chinnadk

Hi Cramik,

Try this.

var doc = app.activeDocument,

    _char = doc.stories.everyItem().characters.everyItem().getElements();

for(var i=0;i<_char.length;i++)

{

        if(_char.capitalization == Capitalization.SMALL_CAPS)

        {

                _char.capitalization = Capitalization.CAP_TO_SMALL_CAP;

            }

    }

Regards,

Chinna

4 replies

Inspiring
July 10, 2014

Thanks Chinna!

Inspiring
July 10, 2014

so I del:

     _selection.capitalization = Capitalization.SMALL_CAPS;

Inspiring
July 10, 2014

Great, Chinna, your great,

but

I want option 2 see below:

Chinnadk
ChinnadkCorrect answer
Legend
July 8, 2014

Hi Cramik,

Try this.

var doc = app.activeDocument,

    _char = doc.stories.everyItem().characters.everyItem().getElements();

for(var i=0;i<_char.length;i++)

{

        if(_char.capitalization == Capitalization.SMALL_CAPS)

        {

                _char.capitalization = Capitalization.CAP_TO_SMALL_CAP;

            }

    }

Regards,

Chinna

cramikAuthor
Inspiring
July 8, 2014

Thx Chinna

This does exactly what I wanted it to do.

Could you make it work for just the selected text?

Chinnadk
Legend
July 8, 2014

For only the selected contents try this.

var doc = app.activeDocument,

    _selection = app.selection[0].characters;

for(var i=0;i<_selection.length;i++)

{

        if(_selection.capitalization == Capitalization.SMALL_CAPS)

        {

                _selection.capitalization = Capitalization.CAP_TO_SMALL_CAP;

            }

    }

Regards,

Chinna