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
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!
Copy link to clipboard
Copied
You can drag the layer to the New Layer Icon in the lower area of the Layers Panel.
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.
Copy link to clipboard
Copied
The program does this to avoid duplicate layer names. You can rename the layer as you please.
Copy link to clipboard
Copied
Yet a duplicated group retains the same name. Seems inconsistent.
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
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...
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.
Copy link to clipboard
Copied
Yes thank you ! Good idea
Copy link to clipboard
Copied
moved to Illustrator Scripting​
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>
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.");
}());
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.");
}());
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);
}());
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)
}
}
}());
Copy link to clipboard
Copied
Yeah, that is a lot more succinct, thank you!
Also hi Mx Pawnshop 🙂
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.
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.
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!
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?
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!
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
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Thank you so much, this is worked amazingly