Skip to main content
Known Participant
February 28, 2024
Question

Can someone share script that changes figure name inside layer from "ALL CAPS" to "Small Caps"

  • February 28, 2024
  • 1 reply
  • 714 views

The case is that we have random number of figures with random shapes and colours that are named inside layer (with random name) with ALL CAPS. The goal is after running the script to change all figure names from "ALL CAPS" to "Small Caps".

Exaple:
RANDOM FIGURE 1

Endgoal:
Random Figure 1

 

This topic has been closed for replies.

1 reply

m1b
Community Expert
Community Expert
February 28, 2024

Hi @D.S.., I think this will do it.

- Mark

 

/**
 * Turn names of all page items to title case.
 * @author m1b
 * @discussion https://community.adobe.com/t5/illustrator-discussions/can-someone-share-script-that-changes-figure-name-inside-layer-from-quot-all-caps-quot-to-quot-small/m-p/14453811
 */
(function () {

    var doc = app.activeDocument;

    for (var i = 0; i < doc.pageItems.length; i++)
        if (doc.pageItems[i].name)
            doc.pageItems[i].name = titleCase(doc.pageItems[i].name);

    app.redraw();

    function titleCase(str) {

        return str
            .toLowerCase()
            .replace(/\b\w/g, function (ch) {
                return ch.toUpperCase();
            });

    };

})();
D.S..Author
Known Participant
February 28, 2024

Script is working sometimes sometimes it crashes illustrator.

Example:
There were like 12-15 objects inside the layer. Object names were "XX-XXX TEXT TEXT TEXT X" where X is number. When script is used illustrator goes "Not Responding" and never responds, like it is stuck.

pixxxelschubser
Community Expert
Community Expert
February 28, 2024

@D.S.. 

Are all layers and objects always unlocked and visible when you execute the script?