Copy link to clipboard
Copied
Is there a way to batch rename artboards in Illustrator CC?
I have 20 different artbords that i want to rename with a specific name and number!
/PÃ¥l
does this do what you are after?
modified a script I wrote to do the same with layers.
...//===========================================================
//
// Rename Artboards
//
//===========================================================
//
// Version 0.1
// 25/5/2015
// Qwertyfly
//
//===========================================================
var doc = app.activeDocument, abs = [];
for(var i = 0; i < doc.artboards.length; i++){
abs.push(doc.artboards.name)
Copy link to clipboard
Copied
Heh. Hein, you guessed it, I'm in my version of the Qwertyfly script make the checkbox "Select all prefix / suffix".
When the mouse cursor is over the scrollbar, the mouse wheel can scroll it. I'll add moving through names using the Up / Down arrows.
And there will be more surprises.
Copy link to clipboard
Copied
Amazing paste!! 😉 Looking forward to it.
Copy link to clipboard
Copied
Sergey I just wanted to say thank you for this amazing work. Awesome stuff!
Copy link to clipboard
Copied
Thank you for your feedback.
Copy link to clipboard
Copied
a little late to the punch. but here's an update that includes buttons for checking all prefixes or suffixes. This only selects all of them.. but it would be trivial to convert it so that it deselects all of them when you click it again, or it could just toggle the value of each checkbox by setting the value to the opposite of the current value, like so:
myCheckbox.value = !myCheckbox.value;
#target Illustrator
function renameArtboards()
{
// Artboard-Name-Editor.jsx
//
// Versions:
// 0.1 Initial version by Qwertyfly (27/5/2015)
// 0.2 added scrollbar (needed full rework) by Qwertyfly (7/6/2015)
// 0.2.1 by Qwertyfly (10/6/2015)
// - bug fix, forgot to initiate the "pre" "nam" & "suf" arrays.
// - added user var for Seperators
// 0.2.2 (05/11/2020) by Sergey Osokin
// - fixed arrays names and indexes
// - fixed scrollbar
// - added isEmpty() function to prevent entering text string has only whitespace
// 0.2.3 (06/3/2021) by William Dowling
// - adding buttons to auto-check all prefix or suffix checkboxes
// - wrapped logic in container function to prevent inserting variables into the global scope
// - added target directive
// User set variable
var SCRIPT_NAME = "Artboard Name Editor",
ROWS = 10, // Number of visible rows.
PREFIX_SEPARATOR = " - ", // Seperator between Prefix and name
SUFFIX_SEPARATOR = " - ", // Seperator between name and Suffix
AB_LIST_HEIGHT = 220; // Artboards names list height;
var doc = app.activeDocument,
abs = [],
item = [],
pre = [],
nam = [],
suf = [];
for (var i = 0; i < doc.artboards.length; i++)
{
abs.push([false, doc.artboards[i].name, false, i]);
}
var w = new Window('dialog', SCRIPT_NAME);
var list = w.add('group');
list.orientation = "Column";
var head = list.add('group');
head.alignment = "left";
var p = head.add('statictext', undefined, "Prefix");
var n = head.add('statictext', [0, 0, 195, 20], " Artboard Name");
var s = head.add('statictext', undefined, "Suffix");
var scrollwin = list.add('group');
scrollwin.alignChildren = "fill";
var items = scrollwin.add("panel");
if (abs.length < ROWS)
{
for (var i = 0; i < abs.length; i++)
{
item = items.add('group');
newLine(i, item);
}
}
else
{
items.maximumSize.height = AB_LIST_HEIGHT;
var grItems = items.add('group');
grItems.orientation = "column";
grItems.alignment = "left";
grItems.margins = [0, 5, 0, 0];
grItems.maximumSize.height = abs.length * 100;
var sbar = scrollwin.add("scrollbar");
sbar.stepdelta = parseInt(ROWS / 2);
sbar.preferredSize.width = 20;
sbar.maximumSize.height = items.maximumSize.height;
for (var i = 0; i < abs.length; i++)
{
item = grItems.add('group');
item.alignment = "left";
newLine(i, item);
}
// Trick from https://community.adobe.com/t5/indesign/scrollable-panel-group-in-scriptui/td-p/10967644?page=1
sbar.onChanging = function()
{
grItems.location.y = -1 * this.value;
}
w.onShow = function()
{
sbar.maxvalue = grItems.size.height - items.size.height + 20;
};
}
function checkAllPrefixes()
{
for (var x = 0; x < pre.length; x++)
{
pre[x].value = true;
}
}
function checkAllSuffixes()
{
for (var x = 0; x < suf.length; x++)
{
suf[x].value = true;
}
}
function newLine(num, item)
{
pre[num] = item.add('checkbox', undefined, "");
pre[num].value = abs[num][0];
pre[num].label = abs[num][3];
pre[num].onClick = function()
{
abs[this.label][0] = !abs[this.label][0];
}
nam[num] = item.add('edittext', [0, 0, 200, 20]);
nam[num].characters = 50;
nam[num].text = abs[num][1];
nam[num].label = abs[num][3];
nam[num].onChange = function()
{
if (isEmpty(this.text))
{
this.text = abs[num][1];
}
else
{
abs[this.label][1] = this.text;
}
}
suf[num] = item.add('checkbox', undefined, "");
suf[num].value = abs[num][2];
suf[num].label = abs[num][3];
suf[num].onClick = function()
{
abs[this.label][2] = !abs[this.label][2];
}
}
var sep1 = list.add("panel");
sep1.alignment = ["fill", "fill"];
sep1.minimumSize.height = sep1.maximumSize.height = 2;
var prefixt = list.add('statictext', undefined, "Prefix to add to checked artboards");
var prefix = list.add('edittext', [0, 0, 280, 20], "");
var sep2 = list.add("panel");
sep2.alignment = ["fill", "fill"];
sep2.minimumSize.height = sep2.maximumSize.height = 2;
var prefixt = list.add('statictext', undefined, "Suffix to add to checked artboards");
var suffix = list.add('edittext', [0, 0, 280, 20], "");
var sep3 = list.add("panel");
sep3.alignment = ["fill", "fill"];
sep3.minimumSize.height = sep3.maximumSize.height = 2;
var ButtonGroup = w.add("group");
ButtonGroup.margins = [0, -10, 0, -8];
ButtonGroup.alignment = "right";
var allPreBtn = ButtonGroup.add('button', undefined, 'Check All Prefixes');
var allSufBtn = ButtonGroup.add('button', undefined, 'Check All Suffixes');
var go = ButtonGroup.add("button", undefined, "OK");
var stop = ButtonGroup.add("button", undefined, "Cancel");
//button functions
allPreBtn.onClick = checkAllPrefixes;
allSufBtn.onClick = checkAllSuffixes;
stop.onClick = function()
{
w.close();
}
go.onClick = function()
{
var validatePre = false,
validateSuf = false,
validateMessage = "";
for (var i = 0; i < abs.length; i++)
{
if (abs[i][0] == true && isEmpty(prefix.text))
{
validatePre = true;
}
if (abs[i][2] == true && isEmpty(suffix.text))
{
validateSuf = true;
}
}
if (validatePre == true)
{
validateMessage = "Artboards have been marked for Prefix, but no Prefix entered\n"
}
if (validateSuf == true)
{
validateMessage = validateMessage + "Artboards have been marked for Suffix, but no Suffix entered"
}
if (validateMessage != "")
{
alert(validateMessage);
}
else
{
w.close();
goTime();
}
}
w.show();
function goTime()
{
for (var i = 0; i < abs.length; i++)
{
var name = abs[i][1];
var pr = "";
var su = "";
if (abs[i][0] == true)
{
pr = prefix.text + "" + PREFIX_SEPARATOR
}
if (abs[i][2] == true)
{
su = SUFFIX_SEPARATOR + "" + suffix.text
}
doc.artboards[i].name = pr + name + su;
}
}
function isEmpty(str)
{
return str.replace(/\s/g, '').length == 0;
}
}
renameArtboards();
Copy link to clipboard
Copied
I decided to make a monster 3 in 1: rename the artboards, layers, and selected objects in separate tabs and add different sets of placeholders.
I have yet to mount a demo video on my channel and post this script on Github. 🙂
Copy link to clipboard
Copied
this looks awesome! let me know if i can assist in any way. i'd love to contribute! 😃
Copy link to clipboard
Copied
Hello @Sergey Osokin really impresive work bro. 🙌 Did you get a chance to finish this monster version. Would love to take a look.
Copy link to clipboard
Copied
Hi all. Happy New Year. Six months passed and I uploaded the "BatchRenamer.jsx" script to my Github: https://github.com/creold/illustrator-scripts. 😄 A short description of the script is in the category "Artboards". Second demo >>>
Copy link to clipboard
Copied
it looks amazing! thanks for sharing Sergey!
Copy link to clipboard
Copied
THANK YOU!
Copy link to clipboard
Copied
Thanks a lot!!
Wondering if possible to have a sript for inert a word or add that can add on to this BatchRenamer.jsx? Like xxxxx-insert-xxxxx-1? Thanks
Copy link to clipboard
Copied
You can use the "Find and Replace" option to take a word that is in all names and add another word to it
Copy link to clipboard
Copied
I think is different, because I duplicated 6 artboards and try to add/insert an "A", "B", "C"...etc. Example: adobe-artboard-a-name, adobe-artboard-b-name...?
Many Thanks
Copy link to clipboard
Copied
Thanks a million!
But I found it has a minor error while I try to renumber the artboard start from 1 {nd:1}
It counts in a wierd way >> 01, 00, -01, -02, -03... etc.
Wondering is it just me? (using 2023)
Here's the sceenshot of my setting
And when I click OK, all other artboards' name are replaced (not including the keyword in "Find")
What I need is that I'll have different groups of artboard and all start from number "1"
Such as : A-1, A-2, A-3 / B-1, B-2, B-3/ C-1, C-2, C-3, C-4
Is there any better way to make it with this script?
Would really appriciate with your help on this!
Copy link to clipboard
Copied
Happy new year @Sergey Osokin! Can you please send your Github profile? I'd love to see the current version of this script.
Copy link to clipboard
Copied
Hello, Wondering if you get a chance to make this script. It will be useful for automatic numbering! Will save me tons of time 🙂
Copy link to clipboard
Copied
Looks like sergey got busy. I added the requested buttons. let me know how it goes. 😃
Copy link to clipboard
Copied
Neat, thanks man.
Copy link to clipboard
Copied
Hello thanks alot for making our work easier but just 1 qn
does the script work on Mac Os too?
Copy link to clipboard
Copied
Hi. Yes, the script is universal for Win and Mac.
Copy link to clipboard
Copied
var doc = app.activeDocument;
for(var i = 0; i < doc.artboards.length; i++){
doc.artboards[i].name="INSERT-NAME-HERE"+"-"+(i+1);
}
Place whatever name you want your artboards to have inside the quotes of "INSERT-NAME-HERE".
Place the above code in a .js file, and run from "File->Scripts->Other Script" in Adobe Illustrator.
Copy link to clipboard
Copied
@Sergey Osokin Thanks for the work you do! Would it be easy to add a function to the script to find and replace only on certain artboards? Or to select artboards in the Artboards panel as an input to the script? That would make it super useful for me.
Copy link to clipboard
Copied
I will consider your request. Unfortunately, selected artboards in the Artboards panel are not available for scripting.
Copy link to clipboard
Copied
Major changes BatchRenamer v1.4-1.5 :
- Buttons to import and export a list of names from TXT files
- Find and replace names in a custom range