Skip to main content
Known Participant
Feb 7, 2012 5:20 PM UTC
Answered

Sort artboards by name

We have over 50 artboards in most of our documents.  Is there a way to sort the artboards as listed in the artboards panel by name via script?

This topic is closed to new replies. Start a new post to keep the conversation going.
CarlosCanto
CarlosCantoCorrect answer
Community Expert
Feb 22, 2012 4:03 AM UTC

No way with actions, javascript, vb or any other means to automate this task? Holding out hope if anyone has any ideas J


do you still need it? here's a script, it only works with numbers for now, it needs more work if there are alpha characters in the artboard names.

#target illustrator

// script.name = sortArtboardsNumericallyCS5only.jsx;

// script.description = reArranges the Artboards indexes (for now works with Numbers only)

// script.required = an open document with at least 2 artboards, CS5 only;

// script.parent = CarlosCanto; // 2/21/12;

// script.elegant = false;

var idoc = app.activeDocument;

var abs = idoc.artboards;

var abcount = abs.length; // save the artboard count

var absNames = []; // array to hold artboards names

for (i=0; i<abcount; i++) {

    absNames = abs.name; // get all artboard names in an array

}

absNames.sort(function (a,b) { return a-b }); // sort Numerically

// duplicate all artboards, in order according to the sorted array

for (j=0; j<abcount; j++) {

                        var newAB = idoc.artboards.add(abs.getByName(absNames).artboardRect); // duplicate AB, which one? go by the sorted array

            newAB.name = absNames; // rename artboard

}

// delete original set of artboards

for (k=abcount-1; k>=0; k--) {

        idoc.artboards.remove(k);

}

15 replies

Known Participant
Aug 2, 2020 9:53 PM UTC

This script works for me.

 

#target illustrator

var doc = app.activeDocument;
var artboards = doc.artboards;
var artboard_count = artboards.length; // save the artboard count
var artboard_names = []; // array to hold artboards names

for (i=0; i<artboard_count; i++)
{
    artboard_names.push(artboards[i].name);
}

artboard_names.sort();

for (j=0; j<artboard_count; j++)
{ 
    var aname = artboard_names[j];
    var rect = artboards.getByName(aname).artboardRect;
    var newAB = artboards.add(rect); // duplicate AB, which one? go by the sorted array
    newAB.name = artboard_names[j]; // rename artboard
}

// delete original set of artboards
for (k=artboard_count-1; k>=0; k--)
{
    artboards.remove(k);
}

 

Translate
Known Participant
Feb 9, 2012 5:35 PM UTC

Anyone have any ideas on this?

Translate
Inspiring
Feb 9, 2012 7:02 PM UTC

I don't think that there are any methods for doing this…

Translate
Known Participant
Feb 9, 2012 10:54 PM UTC

No way with actions, javascript, vb or any other means to automate this task? Holding out hope if anyone has any ideas J

Translate