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

Renaming multiple artboards/layers, specifically removing the word copy.

Community Beginner ,
Nov 07, 2023 Nov 07, 2023

Hi all, 

So I'm wondering if there's a script or plugin that would allow me to bulk edit layer names and artboard names, even if it's round-tripping out to a file I edit in notepad. 

Here's my scenario, I work with multple artboards for advertising and usually use an existing artboard spread to start. So being able to rename all the boards to the new campaign would be super handy. 

 

Also when building a multi-variat campaign, I'll drag a copy of all the selected artboards over, but this adds "copy" and then "copy copy" or "copy2" Ideally it would be great if I could just have a list of the artboards, do the whole find and replace thing and maybe make tweaks to the layer names if need be. 

There's probably a script or plugin for this, I doubt this is a scenario that hasn't played out for someone else, it would be a big time-saver for me. 

 

Thanks
-S 

TOPICS
Actions and scripting , Windows
2.6K
Translate
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

Participant , Nov 07, 2023 Nov 07, 2023

Give this script a try:

var dialog = new Window("dialog");
dialog.text = "Layer Name Renamer";

var but1 = dialog.add("button", undefined, "Export layer names");
var but2 = dialog.add("button", undefined, "Rename layers");
var but3 = dialog.add("button", undefined, "Exit");

var doc = app.activeDocument;

var txtFile = File("/path/to/layerNames.txt");


function exportNames() {
	txtFile.open('w');

	for(i=0; i<doc.layers.length; i++) {
		txtFile.writeln(doc.layers[i].name);
		for(j=0; j<doc.layer
...
Translate
Community Expert , Nov 07, 2023 Nov 07, 2023

The following script has served me well for many years:

 

https://github.com/Paul-Riggott/PS-Scripts/blob/master/Layer%20Name%20Edit.jsx

 

2023-11-08_12-24-31.png

 

You can change the dialog colour from:

 

var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);

 

To:

 

var myBrush = g.newBrush(g.BrushType.THEME_COLOR, "appDialogBackground");

 

Translate
Adobe
Participant ,
Nov 07, 2023 Nov 07, 2023

Give this script a try:

var dialog = new Window("dialog");
dialog.text = "Layer Name Renamer";

var but1 = dialog.add("button", undefined, "Export layer names");
var but2 = dialog.add("button", undefined, "Rename layers");
var but3 = dialog.add("button", undefined, "Exit");

var doc = app.activeDocument;

var txtFile = File("/path/to/layerNames.txt");


function exportNames() {
	txtFile.open('w');

	for(i=0; i<doc.layers.length; i++) {
		txtFile.writeln(doc.layers[i].name);
		for(j=0; j<doc.layers[i].layers.length; j++) {
			txtFile.writeln(doc.layers[i].layers[j].name);
		}
	}

	alert("Layer names written to: " + txtFile);
}

function renameLayers() {
	txtFile.open('r');

	var layerNames = txtFile.read().split("\n");

	var c = 0;

	for(i=0; i<doc.layers.length; i++) {
		doc.layers[i].name = layerNames[c];
		c++;
		for(j=0; j<doc.layers[i].layers.length; j++) {
			doc.layers[i].layers[j].name = layerNames[c];
			c++;
		}
	}

	alert("Layers renamed");
}

function endScript() {
	dialog.close();
}


but1.onClick = exportNames;
but2.onClick = renameLayers;
but3.onClick = endScript;

dialog.show();

 

Before you execute the script, make sure to create an empty text file and update the path to it inside the script. The script writes all layer names into that file like this:

txtBefore.PNG

This is the corresponding Layers panel inside Photoshop:

psBefore.PNG

 

After making adjustments to the individual lines inside the text file...

txtAfter.PNG

 ...and running the script again, the layer names get renamed as desired:

psAfter.PNG

 

Make sure not to change the layer order inside Photoshop between exporting and renaming layer files via the script. Have fun.

____________________
Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5
Translate
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 ,
Nov 08, 2023 Nov 08, 2023

This is awesome, I'll give it a go. I've run  scripts in Illustrator a fair bit, Photoshop scripts are new territory for me. 

Translate
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 ,
Nov 07, 2023 Nov 07, 2023

The following script has served me well for many years:

 

https://github.com/Paul-Riggott/PS-Scripts/blob/master/Layer%20Name%20Edit.jsx

 

2023-11-08_12-24-31.png

 

You can change the dialog colour from:

 

var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);

 

To:

 

var myBrush = g.newBrush(g.BrushType.THEME_COLOR, "appDialogBackground");

 

Translate
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 ,
Nov 08, 2023 Nov 08, 2023

I can definitely use this in my workflow. 

Translate
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 ,
Nov 08, 2023 Nov 08, 2023

@GhostPROD 

 

Please remember to come back and mark the replies that were the "correct answers".

Translate
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 ,
Nov 15, 2023 Nov 15, 2023
LATEST

@GhostPROD I have marked the correct answers for you.

Translate
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 ,
Nov 07, 2023 Nov 07, 2023
quote

Also when building a multi-variat campaign, I'll drag a copy of all the selected artboards over, but this adds "copy" and then "copy copy" or "copy2" Ideally it would be great if I could just have a list of the artboards, do the whole find and replace thing and maybe make tweaks to the layer names if need be. 


By @GhostPROD

 

You will need to rename existing layers, but for new layers - double check the layers panel menu, panel options: "Add copy to copied layers and groups" and untick it.

Translate
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 ,
Nov 08, 2023 Nov 08, 2023

Awesome thanks a lot for this, this will help a lot in the future. 

Translate
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