Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sort Illustrator artboards alphabetically - by OMOTI
/**
Kudos to OMOTI
https://community.adobe.com/t5/illustrator/script-to-sort-artboard-list-alphabetically/m-p/9558396?page=1#M77799
*/
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment