Remove the Word “Copy” from All Layers in Illustrator [Download Free Script]

Duplicating layers in Adobe Illustrator adds the word copy to everything in the hierarchy. Download a free script to remove the unwanted suffixes from all layers and sublayers.

In this post you will find a simple script that was created to solve the issue of appended “copy” text on duplicated layers in adobe illustrator. This issue may be extremely frustrating when creating puppets for Adobe Character Animator.  That is because each layer contains lots of sublayers, which also inherit the suffix copy at their layer name when the parent layer is duplicated.

Although the script was created to solve this specific issue, it may be used in other scenarios as well.

The Main Idea

Remove unwanted text from hundreds of layers in a single click instead of wasting hours doing it manually.

The Problem Explained

When creating puppets, the illustration created in Adobe illustrator must follow a very strict hierarchy and naming rules to later function properly in Adobe Character Animator.  That hierarchy includes many (sometimes hundreds or even thousands) of sublayers.

Duplicating one view of a character and adjusting it to be used as a new view is a part of a standard workflow. The problem is that once you duplicate one of the views which includes lots of sublayers, all those sublayers, and their children get the copy suffix at their layer name.

the problem of copy suffix when duplicating complex hierarchies in adobe illustrator

This results in hundreds of layers with an unwanted suffix. To remove it manually can be very frustrating and time-consuming. And in no way can be part of a routine workflow.

the word copy was removed from 2000 layers in a single click

This is a result of running the script (provided in this post) for the above example. Although just  the front head view of a puppet was duplicated. The suffix copy was added  to 2115 layers. Running the script will remove all of those in a single-click operation. Just imagine doing it manually 🤯🤯🤯.

Who Needs this Script?

Download the Script

How to Use this Script

Once you run the script in Adobe Illustrator a small pop up window will appear. 

It looks like this:

simple script window adobe illustrator to remove unwanted text from the ending of all layer names

To remove the word copy and copy followed by numbers, just press the “Remove All”  button. This action will remove the word copy from all layers and sub-layers.

If you use Illustrator in a different language or want to use this plugin for a different purpose just enter a different word in a text field. And press the “Remove all button” afterward.

Works only for Suffix

Please note that the script only searches for the" unwanted" text at the end of each layer name and removes it. If the word Copy is in a middle of a layer name the layer name will not be changed. ( The script does however check for the "unwanted " text followed by a space and a number and removes those options as well).

How to Run Scripts in Adobe Illustrator

There are 2 main ways to run script in Illustrator:

by Going to File --> Scripts --> Other Scripts, and then navigating to where you saved the downloaded .jsx file.

how to run any script in adobe illustrator

Installing the script into Script Menu

If you plan to use the script regularly. The best way would be to put the download .jsx file into the Adobe Illustrator /presets/scripts folder. This way you will always have the script accessible in your menus.

using the remove layer name suffix script when it is installed into scripts menu

Script Logic Explained

You can skip this section if you don’t like coding.  

The script goes over all layers, sublayers and their child sublayers (all sublayers in the hierarchy) and checks if the word copy (as well as copy 1, copy 2, copy 3, etc..) exists at the end of the layer name. 

The word copy is the default option, but there is an editable text field in the script window which you can edit and enter any word that is relevant to your project. 

				
					var myTextToRemove = myWorkPanel.add ('edittext', undefined, 'copy');
				
			
				
					removeUnwantedTextFromLayerName(myTextToRemove.text);

  function removeUnwantedTextFromLayerName(unwantedString){
    totalLayersToRemoveFrom=0;
    //Turn Unwanted string to Regex
    var fullRegexToRemove=new RegExp('\\s'+unwantedString+'(\\s\\d{1,})?$','g');
    //Remove from all layers and sublayers
    try { findLayersAndRemoveRegex(undefined,fullRegexToRemove);} catch(e) {}  
    return totalLayersToRemoveFrom;

}

				
			
				
					function findLayersAndRemoveRegex(layersList,regexToRemove) {
  
    if(!layersList)  layersList = app.activeDocument.layers;

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

        layersList[i].name = layersList[i].name.replace(regexToRemove, '');
        totalLayersToRemoveFrom++;
    
    if (layersList[i].layers.length)   findLayersAndRemoveRegex(layersList[i].layers,regexToRemove)
    
    
    }
  }
				
			

Now What?

Hopefully, now your puppet creation process will become much faster, easier, and more fun. Let us know in the comment section below if the script was helpful to you.  

Stay tuned for new tutorials.

What the * means above
 

Please note, that the links that have * next to them are affiliate links and those help support AnimationGuides.com website. If you decide to purchase something through those links, we will get a small commission that will help us to continue and provide new free content on this website.

For you, going through those links is the same as clicking on a direct link. You will never pay more for products as a result of clicking on our links. If anything, that can actually help you get a better price since we can sometimes negotiate better deals for our readers.

The content on our website is not affected by the affiliate products and always reflects our honest opinion. All the reviews you will find on AnimationGuides.com are unbiased reviews. If a product we recommend does not have a supporting affiliate program, we will still link to it, just with a standard link without the *.

Share via
>