Skip to main content
brandonf95844140
Participant
October 22, 2018
Question

Delete Named Layers

  • October 22, 2018
  • 2 replies
  • 485 views

Hello.

I have two layers that I need to delete from 250 images.  I am looking to create a script to assist me in this.  The Layers are in folder "Information" and the layers are named "Make 1" and "Make 4" .

Can anyone help me with this script, please!

This topic has been closed for replies.

2 replies

Legend
October 22, 2018

del_layer("Make 1")

del_layer("Make 2")

function del_layer(name)

    {

    try {

        var d = new ActionDescriptor();

        var r = new ActionReference();

        r.putName(stringIDToTypeID("layer"), name);

        d.putReference(stringIDToTypeID("null"), r);

        executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);

        }

    catch (e) { alert(e); }

    }

Chuck Uebele
Community Expert
Community Expert
October 22, 2018

Try this script and run it using File>Automate>Batch.

#target photoshop

var doc = activeDocument;

var infoFolder = doc.layers.getByName('Information');

var make1 = infoFolder.layers.getByName('Make 1')

var make4 = infoFolder.layers.getByName('Make 4')

make1.remove();

make4.remove();

Inspiring
October 22, 2018

Chuck is correct, if you want to remove the whole folder though and not just the layers you can do it all in one line.

app.activeDocument.layerSets.getByName("Information").remove();

Using layerSets selects the whole folder.