Skip to main content
subieguy2
Inspiring
June 23, 2015
Answered

Alphabetize text frames, duplicate and make a list in order

  • June 23, 2015
  • 1 reply
  • 2530 views

I am trying to take the selected text, sort it alphabetically, then duplicate all the text so it comes out in a list form.

So if I had the following text selected....

And ran my script....which I have just a vague start on...

#target illustrator

var doc = app.activeDocument;

var selectedItems = doc.selection;

var alphaList = [];

for (i = 0; i < selectedItems.length; i++){

  alphaList.push(selectedItems);

  }

alphaList.sort();

The results would be this....

Anyone have any guidance for me? Thanks in advance!

This topic has been closed for replies.
Correct answer pixxxelschubser

Hi subieguy2‌,

it's not the best way, but it is a way:

#target illustrator

// https://forums.adobe.com/thread/1880702

// Alphabetize text frames, duplicate and make a list in order

var doc = app.activeDocument; 

var selectedItems = doc.selection; 

var alphaList = []; 

for (i = 0; i < selectedItems.length; i++){

    if (selectedItems.typename == "TextFrame") {

        alphaList.push(selectedItems.contents);

        }

    }

alphaList.sort();

var aTF = doc.textFrames.add();

aTF.position = [0,0];

aTF.contents = alphaList.join("\r");

Have fun

1 reply

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
June 23, 2015

Hi subieguy2‌,

it's not the best way, but it is a way:

#target illustrator

// https://forums.adobe.com/thread/1880702

// Alphabetize text frames, duplicate and make a list in order

var doc = app.activeDocument; 

var selectedItems = doc.selection; 

var alphaList = []; 

for (i = 0; i < selectedItems.length; i++){

    if (selectedItems.typename == "TextFrame") {

        alphaList.push(selectedItems.contents);

        }

    }

alphaList.sort();

var aTF = doc.textFrames.add();

aTF.position = [0,0];

aTF.contents = alphaList.join("\r");

Have fun

subieguy2
subieguy2Author
Inspiring
June 24, 2015

Works like a charm! Thanks so much pixxxel schubser‌!