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

Changing names of the layers by script

Explorer ,
Jun 12, 2022 Jun 12, 2022

Copy link to clipboard

Copied

Dear people,

Perhaps you know how should look like the script changing thae names of all layers to random ones?

 

When I export a GeoPDF the software wants from me the names of the layers should be different from each other. For now I have someting like "Layer 1, Layer 1, Layer 1..."

 

It can  be even such names as "hjbjhgdsdklahf". Completely different characters, but random. Just every layer needs to have different name from the others.

 

When it is not so many of them, I can change them manually, but when there is more layers...

 

Thank you for your thoughts,

TOPICS
Draw and design , Scripting , Tools

Views

409

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

correct answers 2 Correct answers

Community Expert , Jun 12, 2022 Jun 12, 2022

Hello,

You can try the following script that will rename layers to Layer 1, Layer 2, Layer 3 and so on.

var _doc = app.documents[0];
var _layers = _doc.layers
for (var l = 0; l < _layers.length; l++) {
    _layers[l].name = 'Layer ' + (l + 1);
}

 

Note: It will not rename the sublayers.

Votes

Translate

Translate
Guide , Jun 12, 2022 Jun 12, 2022

 

var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
    var string1 = "";
    for (var j = 0; j < 10; j++) {
        var n = Math.floor(Math.random() * 24) + 97;
        string1 += String.fromCharCode(n);
    }
    layers[i].name = string1;
}

 

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 12, 2022 Jun 12, 2022

Copy link to clipboard

Copied

There are already scripts that can do it. For example, I'd recommend "RenameItems", provided by Sergey Osokin.

 

RenameItems

 

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 ,
Jun 12, 2022 Jun 12, 2022

Copy link to clipboard

Copied

Hello,

You can try the following script that will rename layers to Layer 1, Layer 2, Layer 3 and so on.

var _doc = app.documents[0];
var _layers = _doc.layers
for (var l = 0; l < _layers.length; l++) {
    _layers[l].name = 'Layer ' + (l + 1);
}

 

Note: It will not rename the sublayers.

Best regards

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 ,
Jun 17, 2022 Jun 17, 2022

Copy link to clipboard

Copied

LATEST

Thank you guys, all of you, for help.

Works like a gold.

No need to worry about sublayers.

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
Guide ,
Jun 12, 2022 Jun 12, 2022

Copy link to clipboard

Copied

 

var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
    var string1 = "";
    for (var j = 0; j < 10; j++) {
        var n = Math.floor(Math.random() * 24) + 97;
        string1 += String.fromCharCode(n);
    }
    layers[i].name = string1;
}

 

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 ,
Jun 12, 2022 Jun 12, 2022

Copy link to clipboard

Copied

I am not familar with GeoPDF, so I don't know if this will be pertanent or not. There is a Preference under Units, to "Identify Object By" and if you choose XML ID each layer becomes unique. Just not sure how it works when saving as or exporting as PDF.

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