Quantcast
Channel: Adobe Community : Discussion List - Illustrator Scripting
Viewing all articles
Browse latest Browse all 3671

Batch Rename Everything

$
0
0

Hello, I want to batch rename everything.

What I want to do is similar to this script:

GitHub - shspage/illustrator-scripts: JavaScript scripts for Adobe Illustrator CSx.

This script collects every textframe to a pop-up window and let you modify the text and replace it.

 

What I want to do is you run a script in a document, open a pop-up window, and it contains the document's tree.

Something like this:

 

  • Layer 1
  • Layer 2
    • PathItem 1
    • PathItem 2
    • GroupItem 1
      • PathItem 3
      • PathItem 4
    • PathItem 5
  • Layer 3

 

And you can modify them like this:

 

layer 1

mainLayer

--rect

--circle

--mainGroup

----icon 1

----icon 2

--stuff

lastLayer

 

Here is some code I go so far:

(function() {  var allLayersName = "";  //store document's tree  var level = 0;  //store item's order  for (var i = 0; i < app.activeDocument.layers.length; i++) {  //loop throught all top layers    loopThroughAllItems(app.activeDocument.layers[i], level);  //go into layers, this is a recursive function  }  alert(allLayersName); //display document's tree  function loopThroughAllItems(elem, level) {    if(elem.typename == "GroupItem" || elem.typename == "Layer") {      allLayersName += Array(level).join("--") + elem.name + "\n";  //Array(level).join("--") means repeat "--" string level times, level = 2 you get "----"      level++;      for (var i = 0; i < elem.length; i++) {  //this line is where I stuck because illustrator doesn't have this kind of api        return loopThroughAllItems(elem.index(i), level);  //I think this line is also not gonna work XDD      }    } else {      if(elem.parent.index(elem.pareent.length-1) == elem) {  //detect if it is last element inside a group or layer        allLayersName += "--".repeat(level) + elem.name + "\n";        level--;  //decrease level so you get proper order      } else {        allLayersName += "--".repeat(level) + elem.name + "\n";  //there is still some items inside the group or layer      }    }  }})();

 

I stuck at line 12, 13 because illustrator doesn't have that api.

I don't know how to get a groupItem or layer's child in proper order.

 

Please Help~


Viewing all articles
Browse latest Browse all 3671

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>