Rename all layers

Hi!
I've a problem to solve this issue.
I need to rename a lot of layers (near 1000).
I've found 2 scripts.
First select object in the document, I've little edit it to cycle selection and remove selection. Here the result:
// Adobe Illustrator CC Scripting
// Select and rename layers
var i, j, k, l;
if (app.documents.length > 0) {
  var doc = app.activeDocument;
  if (doc.selection.length == 0) {
  for (i = 0; i < doc.pageItems.length; i++) {
  //Select object
  doc.pageItems[i].selected = true;
  // HERE I NEED TO RENAME SELECTED LAYER, BEFORE "remove selection".
  //Remove selection
  doc.pageItems[i].selected = false;
Second script make me able to create var "pixelArea" of each object. I need to put that value at the end of each layer name.
I try to put that between in the red area, but give me loop, so Illustrator die.
if (app.documents.length > 0) {
  if (app.activeDocument.selection.length < 1) {
    alert('Select a path first');
  else if (app.activeDocument.selection[0].area) {
    var objects =  app.activeDocument.selection;
  else if (app.activeDocument.selection[0].pathItems) {
    var objects = app.activeDocument.selection[0].pathItems;
  else {
   alert('Please select a path or group.');
  var pixelArea = 0;
  for (var i=0; i<objects.length; i++) {
  if (objects[i].area) {
  var pixelArea = pixelArea + objects[i].area;
  if (pixelArea < 0) var pixelArea = -pixelArea;
  // HERE WE HAVE pixelArea VAR. NEED TO ADD THIS VALUE AT THE END OF SELECTED LAYER NAME
  // SOMETHING LIKE THAT: layer[n].name = layer[n].name + "-" + pixelArea;
Both works (selection/remove selection and area calc, I don't find orking solution for layer name change), but when I combine them together generates the loop.
I'm new with Illustrator scripts, every help could be appreciate.
Really thanks!

Welcome to the forum!
Here's a quick script that might lead you to finding your answer...
    Dim aDoc As Document = app.ActiveDocument
  For Each pi In aDoc.PageItems
    If TypeName(pi.Parent) = TypeName(aDoc.Layers(1)) Then
      Dim layer As Layer = pi.Parent
      'you can rename here
      layer.Name = "New Name"
  End If
Next
Now this is written in .NET so you'll have to translate into JS, but you should get the idea.
Thing is that if you choose to do it the way that you have chosen via pageitems, you will have to find the parent to find the layer that it is on. There might be an easier way if you can elaborate on your objective, at least as far as your first script is concerned...
Does this help?
-TT

Similar Messages

  • (Batch) Renaming of layers?

    Hello everybody!
    Is there a way of renaming all layers and sublayers of a given CS3-Illustrator file in a search-for-string substitute-with-string manor?
    Cheers
    Klaus

    Yupp, as Wade said, a script should be able to do this using the built-in JavaScript replace() and indexOf() methods. Should not be all too complicated (asssuming, there is a simple way to "walk" the layer/ group hierarchy), so someone may be able to quickly throw it together.
    Mylenium

  • Can I rename *selected* layers with scripting?

    Hello forum,
    Let me just start off by saying I know NOTHING about Photoshop scripting.
    But I recently encountered a need to rename a whole stack of layers in a certain file, so I went Googling...
    I came across this Rename Layers script -- http://morris-photographics.com/photoshop/scripts/rename-layers.html
    However, I was specifically interested in only renaming the layers that I have got selected in the Layers panel.
    This script unfortunately renames *ALL* layers in the document.
    Is it even possible to do what I want?
    Thanks.

    Is it even possible to do what I want?
    Yes. And the simplest thing to do is ask Trevor (the author) to tweak the script for you. If he's not slammed with other work, he should be able to help you out.

  • Script to batch rename/number layers in Illustrator CS6

    Is there a script that I can use in Illustrator to batch rename all sub-layers? I would also like to be able to add sequential numbers to each layer too. I saw an older post that contained a script to do this but it seemed outdated and doesn't work on CS6. Here it is for reference, maybe someone can modify it to work for CS6?
    ////START SCRIPT////
    docRef=app.activeDocument;
    topLayers=docRef.layers;
    for(i=0;i<topLayers.length;i++){
    var currLayer=topLayers[i];
    var newNum=i+1;
    currLayer.name="Layer "+newNum;
    subLayers=topLayers[i].layers;
    for(j=0;j<subLayers.length;j++){
      var currSubLayer=subLayers[j];
      var newSubNum=j+1;
      currSubLayer.name="Layer "+ newNum+"."+newSubNum;
      subSubLayers=subLayers[j].layers;
       for(k=0;k<subSubLayers.length;k++){
        var currSubSubLayer=subSubLayers[k];
        var newSubSubNum=k+1;
        currSubSubLayer.name="Layer "+ newNum+"."+newSubNum+"."+newSubSubNum;
    ////END SCRIPT////

    You got me to investigate if other files and layer structures work, and I found one that partially worked. It stopped working after renaming the first top layer and sub-layers within that.
    Here's what kind of worked:
    before: after:
    Here's the structure that I ultimately want to edit and rename. They are the end levels, sub-sub-sub layers. I want all of them to be renamed to "applyColor1" "applyColor2" etc.

  • Rename specified layers

    Hi all, I work in CAD and regularly create PDF files which are imported into illustrator and illustrated there. I export a PDF where each CAD layer is its own page and have used this script (http://bruno.wyldco.com/multipagepdf/) to bring each of those pages into illustrator as its own layer. I have been able to figure out how to modify the script to also open the PDF directly into a template that I use every time. What im needing to figure out now is how i can automate the renaming of the layers. As i have it set now, the script brigns the 5 pages into my template as "Layer 4", "Layer 5", "Layer 6", "Layer 7", "Layer 8". That happens automatically, i cant set the names in the original script as far as i can tell. I would like the script to automatically rename the layers as such:
    Layer 4 = Section
    Layer 5 = Box
    Layer 6 = Shell
    Layer 7 = Fixtures
    Layer 8 = Zones
    If at all possible, id also like the script to do a select all on layer 8 (zones) and release all compound paths.
    Is that possible to do via javascripting? Ive already tried a action, but as im sure you are aware, that doesnt work. i can get the release all compound paths to work as a action of course, but if it just ran automatically at the end of the script that would be best.

    Ive found this script and it looks like it will select all compound paths.
    var docRef=app.activeDocument;
    for(i=0;i<docRef.compoundPathItems.length;i++){
    var pathRef=docRef.compoundPathItems[i];
    pathRef.selected=true;
    I have a issue with using it though becasue i want to use it on only a specific layer and as it is coded now, it tries to do it on the whole document, and if the layers i dont want it to affect are locked, it throws a error that the target layer can not be modified. Also, what needs to be added to the code to release the compound path once it is selected?

  • Animated Gif's - Applying Clone Stamp to all layers

    I have some animated gif's and I want to clone a
    section of all layers that compose it. I have PS2 and PS4. PS2 allows me to open and sample all layers of the GIF but wont let me apply the clone to more than one layer at a time, PS4 wont let me open anymore than the first layer. Is there a solution for this. If not is there anything in Image Ready or Fireworks that will?

    Window --> Animation, frame mode. Select all frames and while selected, do the cloning or whatever.
    Mylenium

  • How can I rename all the images in different folders into a same name ?

    I need to rename all the jpgs in my music folders into "cover.jpg" so my mp3 player will recognize them as album covers, I've tried to use Automator but couldn't find a proper way to do it.
    Could anybody give me a hint about this? BTW I've kept only one picture in a single folder.
    Thanks~~

    I haven't tested this so maybe make a small folder to test on. In Automater create the following workflow
    Ask for Finder Items
    Get Folder Contents (Repeat for each subfolder found)
    Filter Finder Items (set Kind is image)
    Rename Finder Items
    You may need to play with the last one a little but I think Name Single Item should do the trick. This does assume there is only one image file in each folder. I did something similar to change the case of a bunch of random files over multiple directories.

  • I am going to restore my Macbook Pro to it's factory condition. In iTunes I have renamed a lot of my songs. Last time I cleaned off my mac and restored my music I had to rename all those songs again. How do I get itunes to remember all of those names?

    I am going to restore my Macbook Pro to it's factory condition. I do this every once in a while because it seems to improve performance. I backup everything to an external drive and then I restore only what I want from my backup drive. In iTunes I have renamed a lot of my songs. Last time I cleaned off my mac and restored/reloaded my music I had to rename all those songs again. It took me about 2 weeks to reorganize my music. How do I get iTunes to remember all of those names and keep everything exactly the same when I restore/reload the music into iTunes?

    path21place wrote:
    I am going to restore my Macbook Pro to it's factory condition. I do this every once in a while because it seems to improve performance.
    It may seem like it does but it really doesn't.
    Just delete stuff you don't want.
    Last time I cleaned off my mac and restored/reloaded my music I had to rename all those songs again. It took me about 2 weeks to reorganize my music. How do I get iTunes to remember all of those names and keep everything exactly the same when I restore/reload the music into iTunes?
    Use Time Machine, backup everything, do the reinstall (I recommend you don't do it) then restore your user folder with Time Machine.

  • How do i move all layers at once in my GIF

    hi, I have recently switched to adobe fireworks, and its
    really confusing to me. I was wondering how to move all layers at
    one time in my animated GIF. I like moving each frame individually
    and it is taking a LONG long long time! In image ready, it was a
    lot easier for me, in this I cannot seem to figure it out.
    Also how do i move all layers at once onto another image?
    Thanks

    after calling this
    JComboBox CB = new JComboBox();
    CB.addItem("Jan");
    CB.addItem("Feb");
    CB.removeAllItems();
    do this
    CB=null;
    now when u want to add again
    do this
    CB=new JComboBox();
    CB.addItem("bla bla ..");

  • Is there a way to rename all photos in a folder?

    Is there a fast way to rename all the photos in one folder e.g. I have diffreent folders say "wedding" and "birthday" with alot of photos in each. Is there a way to rename all photos in the folder to the same name like all called wedding?
    Also when i open photos they automatically open with preview, do I need to impost them into iPhoto or should they just automatically save there?
    Tracy

    Tracy
    Are these photos in iPhoto? If so, then use the Photos -> Batch Change command.
    IF not then you can use a batch file renamer such as Name Mangler
    iPhoto is a database and can only show pics that have been imported to the DB.
    Regards
    TD

  • Is there a way to select all layers at once?

    I have a bunch of layers, WITHOUT holding down control and clicking each one, one by one, is there a button or shortcut to just auto highlight all the layers, Im trying to move them around evenly together on the canvase at once.
    Thanks

    You can also Select all Layers by clicking on the top, or the bottom, then holding down Shift and clicking on the other (top, or bottom). That will Select the Background, but as Conroy points out, it cannot be Moved, so you might not want to use that, depending on what your next operation will be.
    If you do wish to perform certain operations, including the Background Layer, you can first Dbl-click on it, and convert it to a "regular" Layer.
    Good luck,
    Hunt

  • Renamed all my songs in vision:m's organiser, how do i get the info back for x-f

    hiya i used to have a vision:m, and i renamed all of my songs (sorting out the genres etc), but when i installed x-fi's?organiser, they were mostly all wrongly named, and had gone back to what they orginially were
    is there anything i can do to get them back to their?renamed names? like something i have to have ticked in options or something?
    thanks alot

    I can't help with how to get back the previous tags, except to say that it happened to me also switching from a Rio Karma to and x-fi.
    In media monkey, if you right-click the track on the x-fi, and click on properties, you can edit the tags from there. You can also highlight a lot of tracks in one go, and change them to have the same genre, and it won't change the settings for the other tags.

  • Incorrect functionality of Embedded tag in html page, displaying object on top of all layers of Adobe air application native window

    Title
    Incorrect functionality of embed tag in html loader for adobe air development
    Description
    Problem Description: If we had loaded youtube.com video url in a view stack and navigate to other index of stack or away from we UI screen within the same native window video or embeded tag of flash player or any other embed object will be displayed on top of all screens layer in same position of where the object should be placed in side of html loader only.
    Steps to Reproduce:
    1) go to http://get.straweb.com/StraWebBrowser/StraWebBrowser.air download and install
    2) load 2 tabs and in the 3 tab load video player of youtube.com which will a sample video
    before completing the load of 3 tab which trying to load video from youtube.com, navigate to other tabs 1 or 2 in few second once the flash player of youtube.com video player is load it will display in the current tab or UI screen.
    3) Try navigating to other tabs than youtube.com loaded tab you see the flash player is on top it stable.
    4) navigate to 3 tab and try to navigate to other tab you can observe that so how it will not show that flash player and only visible in that 3 tab which is fine.
    Actual Result: Embedded tag of html page displaying on top of all layers of Adobe air application native window
    Expected Result: Embedded tag of html page should only displayed in side htmlloader
    This you can replicate in any adobe air plugin update and on any Hardware and Environment.
    Applicable to all sdk versions of adobe air.

    Adobe Bugbase: Bug 3823839 Incorrect functionality of embed tag in html loader for adobe air development

  • Can I Batch Rename all files in a Project?

    I have a rather large scale LabVIEW project that I would like to use as the basis for another similar project, so I just made a copy of the entire project directory. In order to avoid conflicts when switching from one project to another, I would like to rename all the files in the new project directory. I know I can rename the files individually within the project, and LabVIEW will automatically update all dependencies--but is there any way to rename ALL (or at least multiple) files from within the project? Or is there any other way that I can rename a large number of files that will update the dependencies and avoid file conflicts. For simplicity, I would probably just append a prefix/suffix to each filename.
    Thank you for your help and suggestions.
    --Phil Lundeen
    CLAD
    Message Edited by TurboPhil on 07-23-2008 09:08 AM

    I wrote a cloner VI just before NI release LV 8.5 where they adde the ability to add a prefix when you do a Source Distribution. Try that.
    Ben
    Message Edited by Ben on 07-23-2008 11:47 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Prefix.PNG ‏33 KB

  • Can I close all layers? or even better, stop illustrator from opening all layers when I open a file?

    I just installed cs6, and when I open files in Illustrator, it opens all of the layers which contain sublayers.  It does this even if all the top-level layers were closed during the previous save.  The files I work with have a large layer-structure, so re-closing the top-level layers every time I open a file wastes a lot of my time.  Can I close all layers at once, or better yet, can I stop Illustrator from opening all of the layers automatically when I load a file?
    If not, then WHY on earth not?  I can't be the only one who opens and closes large files with lots of layers and sub-layers...
    Thanks for your help.
    Edit: I also am noticing this problem is even worse in cs6, because openning and closing individual layers plays a little animation of rotating the triangular arrow before the layer which, cute as it may be, just makes the task of individually closing up all my layers that much more tedious.  Can I turn off that little animation of the triangular arrow when opening and closing layers?

    You can save it as a pdf and when you open that in AI the layers will not be opened even if they have sublayers.
    Not true. Does the same nonsense an .AI file does. Saved as a .PDF, closed Layers/subgroups get opened.
    And no one cares!
    I do. Every other Adobe program with a layering sceme seems to be able to remember that you saved a file with all layers and subs closed. But not this one.
    Maybe someone from the AI development team should ask someone from the Photoshop team how they've managed it.....for decades.

Maybe you are looking for