Script to Sort Artboard List Alphabetically

Community Beginner ,
Nov 15, 2017 Nov 15, 2017

Copy link to clipboard

Copied

I'm on the lookout for a simple script to sort an Illustrator artboard list alphabetically. (I don't need the artboards themselves rearranged on the canvas, just the order of the artboards in the list.)

In the example (image) below, the artboard list reads:

1. life-ring

2. wheelchair-alt

3. wheelchair

4. information

...

30. blind-walking

The desired result would be for the artboard list itself to be sorted to read:

1. assistive-listening

2. assistive-listening-telecoil

3. blind-walking

4. braille

...

30. wheelchair-alt

Screenshot 2017-11-15 09.02.45.png

I've scoured the forums for solutions to this. The closest I could find is here: Sort artboards by name, but it doesn't seem to work in Illustrator CC. Also found this (How to sort objects alphabetically (inside of a layer)?), but it is layer-specific, not artboard.

Thanks so much for any help!

TOPICS
Scripting

Views

3.8K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Nov 18, 2017 Nov 18, 2017
Hi,Artboard object probably has no method for sorting.Since it does not generate an Artboard object, it may run lightly.This try it.function sortArtboard() {    var doc = app.activeDocument,        properties = [],        i,        max;    function copyProperties(source) {        var props = {},            key;        for (key in source) {            try {                props[key] = source[key];            } catch (e) {            }        }        return props;    }    function pasteProperties...

Likes

Translate

Translate
Contributor ,
Nov 18, 2017 Nov 18, 2017

Copy link to clipboard

Copied

Hi,

Artboard object probably has no method for sorting.

Since it does not generate an Artboard object, it may run lightly.

This try it.

function sortArtboard() {

    var doc = app.activeDocument,

        properties = [],

        i,

        max;

    function copyProperties(source) {

        var props = {},

            key;

        for (key in source) {

            try {

                props[key] = source[key];

            } catch (e) {

            }

        }

        return props;

    }

    function pasteProperties(source, destination) {

        var key;

        for (key in source) {

            destination[key] = source[key];

        }

    }

    function compareName(a, b) {

        var comparison = 0;

        if (a.name > b.name) {

            comparison = 1;

        } else if (a.name < b.name) {

            comparison = -1;

        }

        return comparison;

    }

    for (i = 0, max = doc.artboards.length; i < max; i += 1) {

        properties.push(copyProperties(doc.artboards));

    }

    properties.sort(compareName);

    for (i = 0, max = doc.artboards.length; i < max; i += 1) {

        pasteProperties(properties, doc.artboards);

    }

}

sortArtboard();

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 18, 2017 Nov 18, 2017

Copy link to clipboard

Copied

Awesome! That worked exactly as I needed it to. Thank you so much!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 26, 2018 Jul 26, 2018

Copy link to clipboard

Copied

Sorry can you help me? I tried this script but it doesnt work. I'm using Illustrator cc.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

Did you receive an error message when an error occurred?

Which is your "Illustrator cc" CC or CC2018?

It worked with the following versions in my environment. I have not installed CC.

  • Illustrator CS6
  • Illustrator CC 2017
  • Illustrator CC(2018)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

Thank you! I solved it. Needed to save the script as .js insteD of .jsx. Thank you again.

Von meinem iPhone gesendet

Am 27.07.2018 um 18:37 schrieb OMOTI <forums_noreply@adobe.com>:

Script to Sort Artboard List Alphabetically

created by OMOTI in Illustrator Scripting - View the full discussion

Did you receive an error message when an error occurred?

Which is your "Illustrator cc" CC or CC2018?

It worked with the following versions in my environment. I have not installed CC.

Illustrator CS6

Illustrator CC 2017

Illustrator CC(2018)

If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10527623#10527623 and clicking ‘Correct’ below the answer

Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10527623#10527623

To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"

Start a new discussion in Illustrator Scripting by email or at Adobe Community

For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

This email was sent by Adobe Community because you are a registered user.

You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2019 Nov 28, 2019

Copy link to clipboard

Copied

Hello

 

I'm using Illustrator 2020 and while running the script, I'm getting the error "Error:7 Language feature '0' is not supported. Line: 20   destination[key] = source[key];"

Any volonteer to help with this ? I'm not sure if I'm doing something wrong or there is some "new feature" in 2020 version.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 01, 2019 Dec 01, 2019

Copy link to clipboard

Copied

Hi majliniok, transitioning to the new forums ruined all scripts. 

Here's the original script posted by OMOTI

function sortArtboard() {  
    var doc = app.activeDocument,  
        properties = [],  
        i,  
        max;  
  
    function copyProperties(source) {  
        var props = {},  
            key;  
        for (key in source) {  
            try {  
                props[key] = source[key];  
            } catch (e) {  
            }  
        }  
        return props;  
    }  
  
    function pasteProperties(source, destination) {  
        var key;  
        for (key in source) {  
            destination[key] = source[key];  
        }  
    }  
  
    function compareName(a, b) {  
        var comparison = 0;  
        if (a.name > b.name) {  
            comparison = 1;  
        } else if (a.name < b.name) {  
            comparison = -1;  
        }  
        return comparison;  
    }  
  
    for (i = 0, max = doc.artboards.length; i < max; i += 1) {  
        properties.push(copyProperties(doc.artboards[i]));  
    }  
  
    properties.sort(compareName);  
  
    for (i = 0, max = doc.artboards.length; i < max; i += 1) {  
        pasteProperties(properties[i], doc.artboards[i]);  
    }  
  
}  
  
sortArtboard(); 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2019 Dec 01, 2019

Copy link to clipboard

Copied

Thank You ! Now working great 🙂

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 14, 2022 Feb 14, 2022

Copy link to clipboard

Copied

LATEST

is there is any script for reordering artboards by their position?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines