Instantly Swap Left and Right Tags in Illustrator [Download Free Script]

Download a free script to switch between the left and right tags of layer and object names in Adobe Illustrator. Make your workflow fast and simple.

In this post, you will find one more script that can make your workflow of making illustrator puppets for Adobe Character Animator * faster and easier. The script attached here will help you automate the process of mirroring right/left character views by swapping the left and right tags in the names of all the elements.

Using this “Swap Left and Right tags” script together with the “remove copy suffix from all layers ” script (posted earlier) may help you save hours of tedious work.

The Main Idea

Change all layer names and object names to include the word left instead of right and vice versa. 

The Problem Explained

For a puppet to work properly in Adobe Character Animator it should follow a very specific hierarchy and naming convention. One of the rules of this naming standard is that the different facial and body elements of the illustrated character should have right and left tags in their names.

Facial features that are named properly are recognized by Adobe Character Animator automatically and save lots of extra rigging work. For example, an right eye should be named as +Right eye. Below it in the hierarchy there should be right blink, +right pupil, right pupil range etc…

So if we copy the left quarter facial view for example and mirror it to turn it into a right quarter facial view, we will need to find all the tagged layers and rename them. It is possible to do it manually, but it may take some time and effort.

The script in this post is created to automate this process. So once you highlight the top layer of the view you want to swap and run the script, all the left tags will turn into right tags and all the right tags will turn into left tags. All in a single click. 

Who Needs this Script?

How to Use this Script

You should now have a hierarchy with renamed layers. So If you selected to run the script on the “right profile copy” layer: the layer itself will become the “left profile copy”. All the layers and items containing the word “right” in their name will also change:

The above items will now be named:

How to Run Scripts in Adobe Illustrator

There are 2 main ways to run the script in Adobe 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 on a regular basis. 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 swap right and left tags script when installed in the presets folder in illustrator

Script Logic Explained

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

The script goes over all layers  and items which are placed in the hierarchy below the highlighted layer. It finds all the sublayers and items containing the word left and right in their name. Once all the items are located, the script goes over all of them, finds the string matching left or right, and replaces it with the opposite one.

  layersList=  app.activeDocument.activeLayer.layers;

  var topsel=app.activeDocument.selection;
					for (var i = 0; i < layersList.length; i++) {

            var sel=app.activeDocument.selection;

      if (layersList[i].layers.length) findLayersWithLeftAndRightTags(layersList[i].layers)
					function swapLeftAndRightTags(){
    for (var i = 0; i < layersWithLeftTag.length; i++)

      layersWithLeftTag[i].name = layersWithLeftTag[i].name.replace('Left', 'Right');
      layersWithLeftTag[i].name = layersWithLeftTag[i].name.replace('left', 'right');

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

      layersWithRightTag[i].name = layersWithRightTag[i].name.replace('Right', 'Left');
      layersWithRightTag[i].name = layersWithRightTag[i].name.replace('right', 'left');

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

      itemsWithRightTag[i].name = itemsWithRightTag[i].name.replace('Right', 'Left');
      itemsWithRightTag[i].name = itemsWithRightTag[i].name.replace('right', 'left');
    for (var i = 0; i < itemsWithLeftTag.length; i++)

      itemsWithLeftTag[i].name = itemsWithLeftTag[i].name.replace('Left', 'Right');
      itemsWithLeftTag[i].name = itemsWithLeftTag[i].name.replace('left', 'right');


Now What?

If you haven’t already, download the remove the word copy from the end of all layer names script.

Use the comment section below to tell us if the script was helpful and what other processes you would like to automate in your workflow.

Stay tuned for new tutorials.

Notify of
Inline Feedbacks
View all comments
1 year ago

but thanks to Katia for the nice article

1 year ago

whats up with this horrendous sociallockerapp. i just want to download the script. i would even like this on twitter on my account. oh well, adios

1 year ago
Reply to  stageonemedia

Hi, stageonemedia!

Thank you for your thoughts! We’ll take it into an account and maybe remove Social Locker App in the future so the user experince will be better. Yes, I agree, the developers of Social Locker App have made it not ideal and annoying, with many bugs and without good technical support.

What the * means above

Please note, that the links that have * next to them are affiliate links and those help support 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 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