2

I've got a file with over 300 artboards. Each artboard has a unique name e.g. "symbol.hot.surface". I need to replace all the periods "." with an underline "_"

I'm pretty sure this can be done with a script, but that's beyond me. Any help would be greatly appreciated. Thank you.

4

Design Phoenix made an awesome script, I modified the script so that you get a prompt and enter in the values right in Illustrator

Script below:

#target illustrator
var doc = app.activeDocument;

jsfind = prompt("Find: ", "");
jsreplace = prompt("Replace: ", "");

for ( var i=0; i<doc.artboards.length ;i++) {
var aBoard = doc.artboards[i].active;
var oldName = doc.artboards[i].name;
doc.artboards[i].name = oldName.replace (jsfind, jsreplace);
}

Note, this script is case sensitive.


The script can easily be modified to work for layers instead of artboards. FindReplaceLayers.jsx


If you wanted to use REGEX while searching, just add the following line of code to the script:

var jsfindREGEX = new RegExp(jsfind,"g");

In this line replace jsfind with regex

oldName.replace (jsfindREGEX, jsreplace);

You can find both Regex script on Github.

FindReplaceArtboardsREGEX.jsx
FindReplaceLayersREGEX.jsx


And as GerardFalla nicely pointed out, you can also use the layers script in Photoshop which is very helpful.

  • 2
    Moreover that layers script will happily work in Photoshop too (at least on Win 10) though the artboard renamer won't. These are excellent resources - thank you! – GerardFalla Apr 2 at 15:56
  • 2
    That's good to know that it works in PS. It doesn't use keyboards which is why it won't work there. – WELZ Apr 2 at 16:05
  • 1
    I meant to say artboards, not keyboards. – WELZ Apr 2 at 18:05
  • Note that oldName.replace(str1, str2) will replace only the first occurence of str1 and OP's symbol.hot.surface will become symbol_hot.surface. To replace all the occurences you need to use regex instead of a string: oldName.replace(/\./g, str2) – Sergey Kritskiy Apr 3 at 6:05
  • @SergeyKritskiy thanks for that, I've incorporated it into the script. – WELZ Apr 3 at 19:40
2

Save This Code As "ArtboardReplace.jsx" or Whatever You Like

And Go To File-Script-Other Scripts.. And Browse! Enjoy!

//Replace "." with "_" Artboard illustrator script
#target illustrator
var doc = app.activeDocument;
for ( var i=0; i<doc.artboards.length ;i++) {
var aBoard = doc.artboards[i].active; // makes artboard active
var oldName = doc.artboards[i].name;
doc.artboards[i].name = oldName.replace (".", "_"); // replace . with _
}
  • 1
    That's a really great script, I would suggest - to allow it to receive input from the user when the script is run. – WELZ Apr 2 at 12:03
  • WELZ thanks For Doing it. since i was offline ;i was also thinking to do that but grats for doing it :) – Mr.Online Apr 3 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.