Mobile app version of vmapp.org
Login or Join
Pierce403

: How to delete all pixel layers in Photoshop I have designed a website template in Photoshop CC2014 and after making this I have to upload it on a server for my client, but before this I

@Pierce403

Posted in: #Actions #Images #Layers #PhotoshopScripting #Selections

I have designed a website template in Photoshop CC2014 and after making this I have to upload it on a server for my client, but before this I want to delete all images (pixel layers) from .psd files. There are 80+ PSDs so can anyone help me in deleting image (pixel layers) from PSDs, Excluding Background Layer?

This would be great if you can give me action or script.

I know doing pixel filter can help but this is a very slow process.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pierce403

1 Comments

Sorted by latest first Latest Oldest Best

 

@Berryessa866

This script will loop through all your layers and groups and delete any normal (pixel) layers. It will record the deletions in the history (as a single history state, thanks Joonas) but PLEASE save before using this and test it thoroughly as I've only done limited testing.

var doc = app.activeDocument;
doc.suspendHistory("Remove Normal Layers", "deletePixelLayers( doc )");

function deletePixelLayers(target)
{
try{
var layers = target.layers;
for (var i = 0; i < layers.length; i++)
{
var curLayer = layers[i];
var visible = curLayer.visible; // remember visibility
curLayer.allLocked = false; // unlock layer

// Layer is a group
if ("LayerSet" == curLayer.typename) {
deletePixelLayers(curLayer);
}

// Layer is a NORMAL (Pixel) Layers
if (LayerKind.NORMAL == curLayer.kind
&& !curLayer.isBackgroundLayer) {

curLayer.remove(); // Delete the layer
--i;
};

// restore layer visibility
if (curLayer) curLayer.visible = visible;
};
}catch(e){
; // do nothing
}
};
deletePixelLayers(doc);

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme