Copy link to clipboard
Copied
I don't know anything about scripting. I wanted to know if it were possible to make a script that will rename the artboard that is currently selected to a different name.
For example. I have a document that has 4 artboards on it. All 4 of the artboards already have current names, (Proof, Artwork, etc.). I need to add a new artboard to the existing document. The new artboard has "Artboard 5" as the name. I need to change that to "Job Jacket". However, I need to do this for thousands of files, so I need a streamlined way to do it rather than clicking and typing through the artboards panel.
Other notes; some of the existing documents will have less existing artboards, and some will have more artboards. This is why I ask if there is a way to only rename the currently selected artboard.
Is this possible?
Try that
// set a new name eg "Job Jacket" for the active artboard in active document
var aDoc = app.activeDocument;
var abIdx = aDoc.artboards.getActiveArtboardIndex ();
aDoc.artboards[abIdx].name = "Job Jacket"; // set the new name here
Have fun
Copy link to clipboard
Copied
Try that
// set a new name eg "Job Jacket" for the active artboard in active document
var aDoc = app.activeDocument;
var abIdx = aDoc.artboards.getActiveArtboardIndex ();
aDoc.artboards[abIdx].name = "Job Jacket"; // set the new name here
Have fun
Copy link to clipboard
Copied
Adding to pixxxel schubser’s great example: If a simple interactive method is required:
// https://forums.adobe.com/message/11034337#11034337
// set a new name eg "Job Jacket" for the active artboard in active document via prompt
var aDoc = app.activeDocument;
var abIdx = aDoc.artboards.getActiveArtboardIndex ();
var abName = prompt("Rename Active Artboard" + "\n" + "Enter a new name:", "Job Jacket");
aDoc.artboards[abIdx].name = abName;
Copy link to clipboard
Copied
Stephen_A_Marsh wrote
Adding to https://forums.adobe.com/people/pixxxel+schubser great example: If a simple interactive method is required:
// https://forums.adobe.com/message/11034337#11034337 // set a new name eg "Job Jacket" for the active artboard in active document via prompt var aDoc = app.activeDocument; var abIdx = aDoc.artboards.getActiveArtboardIndex (); var abName = prompt("Rename Active Artboard" + "\n" + "Enter a new name:", "Job Jacket"); aDoc.artboards[abIdx].name = abName;
This is really cool and might come in handy. For this specific task, I wanted to make the process as quick as possible. Thanks for the script though. It might help someone else looking for something similar too!
Copy link to clipboard
Copied
Thanks for the thanks! I guessed that it was probably overkill for your situation, however as I'm new to scripting and mostly hack away with Photoshop scripts it was a good exercise for me to reinforce these basic concepts. It was a simple enough and logical extension of the previous script so if it helps somebody else that is great!
Copy link to clipboard
Copied
Hi Stephen,
also provide something in case someone will press the Cancel button. Then the prompt will return null or undefined.
( function()
{
if( app.documents.length == 0 ){ return };
var aDoc = app.activeDocument;
var abIdx = aDoc.artboards.getActiveArtboardIndex();
var abName = prompt( "Rename Active Artboard" + "\n" + "Enter a new name:", "Job Jacket" );
// User pressed the Cancel button:
if( abName == null ){ return };
aDoc.artboards[abIdx].name = abName;
}() )
One should also note that if the prompt returns an empty string, which means not null or undefined, Illustrator will rename the artboard to a default value.
And that depends on the locale of the Illustrator version. My German Illustrator defaults to the name "Zeichenfläche n" where n is a number.
Regards,
Uwe
Copy link to clipboard
Copied
Thank you Uwe! I think that this is the 2nd time that I have used the prompt, I was pretty much bluffing my way through from what I had explored using alert. Thank you for extending my knowledge!
Trying this in Photoshop on a layer resize variable, if cancel is pressed then the layer content is removed (I’m guessing that null is not a number).
I found this but have not been able to find a solution:
Copy link to clipboard
Copied
Hi Stephen,
can you point to a discussion in the PhotoShop Scripting Forum concerning Cancel when using a Prompt and removing the layer content as consequence? ( That discussion should be done over there, I think. )
Regards,
Uwe
Copy link to clipboard
Copied
Thanks Uwe, I just created the topic as this was previously only a personal exercise for learning:
Copy link to clipboard
Copied
https://forums.adobe.com/people/pixxxel+schubser wrote
Try that
// set a new name eg "Job Jacket" for the active artboard in active document var aDoc = app.activeDocument; var abIdx = aDoc.artboards.getActiveArtboardIndex (); aDoc.artboards[abIdx].name = "Job Jacket"; // set the new name here
Have fun
Thank you so much! This is perfect. Exactly what I needed. Now I can assign this script a keyboard shortcut and my life is sooo much easier now! THANK YOU!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now