• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Duplicate a layer without changing the name (without "... - copy"

Community Beginner ,
Sep 05, 2017 Sep 05, 2017

Copy link to clipboard

Copied

Hello !

I would like to know if there is a parameter in order to : when you duplicate a layer, the name of the layer don't change ?

For example :

I want to duplicate the layer "My layer". But, I don't want that my new layer is called "My layer - copy".

Is-it possible ?

Thank you for your answer

TOPICS
Scripting

Views

8.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advisor ,
Sep 05, 2017 Sep 05, 2017

Copy link to clipboard

Copied

You can drag the layer to the New Layer Icon in the lower area of the Layers Panel.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 05, 2017 Sep 05, 2017

Copy link to clipboard

Copied

But "Copy" is still added whether option dragging or dragging to "Layer" icon. I don't know of a way around this. I suppose it could be scripted.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 05, 2017 Sep 05, 2017

Copy link to clipboard

Copied

The program does this to avoid duplicate layer names. You can rename the layer as you please.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 05, 2017 Sep 05, 2017

Copy link to clipboard

Copied

Yet a duplicated group retains the same name. Seems inconsistent.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2017 Sep 05, 2017

Copy link to clipboard

Copied

Make sure you understand that the layering system is different in AI.

You can have as many path or shapes in one layer. It is for organization. So naming convention is important

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 06, 2017 Sep 06, 2017

Copy link to clipboard

Copied

Thank you for your answers !

I have a lot of views with the common elements and it's painful to rename every time !

But there seems to be no solution...

screen.JPG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2017 Sep 06, 2017

Copy link to clipboard

Copied

You should ask over on the Illustrator Scripting Forum, it might be possible to automate the duplicating and renaming and reduce it to a one keystroke task.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 06, 2017 Sep 06, 2017

Copy link to clipboard

Copied

Yes thank you ! Good idea

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 21, 2017 Nov 21, 2017

Copy link to clipboard

Copied

moved to Illustrator Scripting​

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2017 Sep 06, 2017

Copy link to clipboard

Copied

I know it is painful. Solution is to group the elements and name the groups.

On Wed, Sep 6, 2017 at 12:31 AM, camilled30241157 <forums_noreply@adobe.com>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 22, 2017 Nov 22, 2017

Copy link to clipboard

Copied

Hi.

This script erases the words following " - copie" included in the name.

It might help your work a little.

(But I yet don't know whether it can rename all types of object.)

For example:

"my layer - copie" -> "my layer"

"my layer - copie 2" -> "my layer"

"my layer - copie 2 - copie" -> "my layer"

"my - copie layer" -> "my"

Please try to run this script:

(function () {

    if (app.documents.length === 0) {

        return;

    }

   

    var doc = app.activeDocument,

        count = 0,

        targetString = " - copie",

        i,

        max;

   

    function removeStringAfter(searchValue, obj) {

        var name = obj.name,

            index = name.indexOf(searchValue),

            count = 0;

        if (index > -1) {

            obj.name = name.slice(0, index);

            count += 1;

        }

        return count;

    }

   

    for (i = 0, max = doc.pageItems.length; i < max; i += 1) {

        count += removeStringAfter(targetString, doc.pageItems);

    }

   

    // layers and sublayers

    (function resursion(layers) {

        for (i = 0, max = layers.length; i < max; i += 1) {

            count += removeStringAfter(targetString, layers);

            if (layers.layers.length > 0) {

                resursion(layers.layers);

            }

        }

    }(doc.layers));

   

    // clipped groupItems

    for (i = 0, max = doc.groupItems.length; i < max; i += 1) {

        count += removeStringAfter(targetString, doc.groupItems);

    }

    alert(count + " names have been changed.");

}());

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 19, 2018 Jul 19, 2018

Copy link to clipboard

Copied

That naming behavior bugged me for a long time as i often have to deal with multiple equally named layer stacks. The scripting solution is nice and very fast but your script has a little bug that prevents it (at least for my  Mac AI CC 2018) to go beyond the topmost layer and its child layers. Here is the fix:

(function () {

  if (app.documents.length === 0) {

  return;

  }

  var doc = app.activeDocument,

  count = 0,

  targetString = " - copie";

//  targetString = " Kopie"; // german version

  function removeStringAfter(searchValue, obj) {

  var name = obj.name,

  index = name.indexOf(searchValue),

  count = 0;

  if (index > -1) {

  obj.name = name.slice(0, index);

  count += 1;

  }

  return count;

  }

  for (i = 0, max = doc.pageItems.length; i < max; i += 1) {

  count += removeStringAfter(targetString, doc.pageItems);

  }

  // layers and sublayers

  (function resursion(clayers) {

  var max = clayers.length;

  for (var i=0; i<max; i++) {

  count += removeStringAfter(targetString, clayers);

  if (clayers.layers.length > 0) {

  resursion(clayers.layers);

  }

  }

  }(doc.layers));

  // clipped groupItems

  for (i = 0, max = doc.groupItems.length; i < max; i += 1) {

  count += removeStringAfter(targetString, doc.groupItems);

  }

  alert(count + " names have been changed.");

}());

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

This was not working for me on Illustrator 2020. I beat on it a bit until it did:

 

(function () {
    if (app.documents.length === 0) {
        return;
    }
    
    var doc = app.activeDocument,
        count = 0,
        targetString = " copy",
				allnames = "LAYER NAMES:\n";
    
    function removeStringAfter(searchValue, obj) {
        var name = obj.name,
            index = name.indexOf(searchValue),
            count = 0;
						
				allnames += name+"\n";
				
        if (index > -1) {
					// alert ("renaming "+name);
            obj.name = name.slice(0, index);
            count += 1;
        }
        return count;
    }
        
    // layers and sublayers
    (function recursion(thelayers) {

	        for (var i = 0; i < thelayers.length; i++) {

            count += removeStringAfter(targetString, thelayers[i]);

            if (thelayers[i].layers.length > 0) {
                recursion(thelayers[i].layers);
            }
        }
    }(doc.layers));
    
    alert(count + " names have been changed.");
		// alert (allnames);
		
}());

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Hi u/egypturnash, I see you on Reddit all the time (over there I'm u/portablepawnshop). Try this:

 

(function () {
  updateLayerNames()
  function updateLayerNames(list) {
    if (arguments.length < 1) list = app.activeDocument.layers;
    for (var i = 0; i < list.length; i++) {
      list[i].name = list[i].name.replace(/\scopy(\s\d{1,})?$/g, "");
      if (list[i].layers.length) updateLayerNames(list[i].layers)
    }
  }
}());

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2020 Jan 06, 2020

Copy link to clipboard

Copied

Yeah, that is a lot more succinct, thank you!

 

Also hi Mx Pawnshop 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2017 Nov 22, 2017

Copy link to clipboard

Copied

function test()

{

     var docRef = app.activeDocument;

     var layers = docRef.layers;

     var layerCopy = layers[0].duplicate();

     layerCopy.name = layers[0].name;

}

test();

Woops. disregard the above. duplicate is not a method of the layer class.

my sincere apologies.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2018 Jun 27, 2018

Copy link to clipboard

Copied

Hello,

This minor problem of Illustrator automatically adding "copy" to a duplicated layer's name as well as to all its sub-layers has annoyed me as well. Especially if there are a lot of sub-layers, and you want them to retain their original names. I think I've got a simple and helpful workaround:

1) Turn ON "Paste Remembers Layers" in the Layers palette.

2) UNLOCK and make visible everything in the layer that you are duplicating.

3) SELECT everything in that layer and COPY to the clipboard.

4) RENAME the original layer (i.e. add 1 to the end of the name).

5) PASTE in FRONT (⌘+F). Illustrator will create a new layer with the original layer and sub-layers' names and contents.

6) Change the original layer's name back, if you wish.

I hope this helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 26, 2018 Nov 26, 2018

Copy link to clipboard

Copied

THANK YOU! THANK YOU!

This is exactly the kind of workaround I've been looking to find for years, and I just got so frustrated I decided to check again.

You ROCK!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2018 Nov 26, 2018

Copy link to clipboard

Copied

seriously? the workaround seems like a lot more work. Turning on Paste remembers layers, renaming source layer, renaming back source layer after pasting...isn't easier to rename duplicate layer?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 28, 2020 Jan 28, 2020

Copy link to clipboard

Copied

The workaround might be more work if you only have to copy one layer, but if you have a layer that you have to copy multiple times, with hundreds of sub-layers inside that you would have to rename for each one, that workaround is a lifesaver. This is a problem that has plagued me since I started using Adobe Character Animator. Thank you, SkeetsTreats!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 28, 2020 Jan 28, 2020

Copy link to clipboard

Copied

I think Carlos' point was that if you use a script (like ones provided in the above replies), you only need click a button regardless if there's one layer or hundreds, and no matter the depth. In comparison any manual workaround can't compare

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

LATEST

So, I don´t really know why this works for me but I hope it's not just luck.
Turn ON "Paste Remembers Layers" in the Layers palette.
then select the group you want to copy by clicking on the target.
then Ctrl + C and Ctrl + F.

I don´t know why but it works for me, hope this helps!

ronaldr24038915_0-1620140035259.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines