Skip to main content
Known Participant
February 7, 2012
Answered

Sort artboards by name

  • February 7, 2012
  • 2 replies
  • 5915 views

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 has been closed for replies.
Correct answer CarlosCanto

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);

}

2 replies

Known Participant
August 2, 2020

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);
}

 

Known Participant
February 9, 2012

Anyone have any ideas on this?

Inspiring
February 9, 2012

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

Known Participant
February 9, 2012

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